mirror of
https://github.com/python/cpython.git
synced 2025-08-30 05:35:08 +00:00
Invalid patterns to substitute and safe_substitute would crash since pattern
is not a local variable. Add a test case.
This commit is contained in:
parent
1338946c7b
commit
6627a96705
2 changed files with 16 additions and 2 deletions
|
@ -167,7 +167,8 @@ class Template:
|
|||
return self.delimiter
|
||||
if mo.group('invalid') is not None:
|
||||
self._invalid(mo)
|
||||
raise ValueError('Unrecognized named group in pattern', pattern)
|
||||
raise ValueError('Unrecognized named group in pattern',
|
||||
self.pattern)
|
||||
return self.pattern.sub(convert, self.template)
|
||||
|
||||
def safe_substitute(self, *args, **kws):
|
||||
|
@ -199,7 +200,8 @@ class Template:
|
|||
return self.delimiter
|
||||
if mo.group('invalid') is not None:
|
||||
self._invalid(mo)
|
||||
raise ValueError('Unrecognized named group in pattern', pattern)
|
||||
raise ValueError('Unrecognized named group in pattern',
|
||||
self.pattern)
|
||||
return self.pattern.sub(convert, self.template)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue