summaryrefslogtreecommitdiff
path: root/Lib/string.py
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2004-10-17 16:27:18 +0000
committerNeal Norwitz <nnorwitz@gmail.com>2004-10-17 16:27:18 +0000
commite4747ec4e0c4a84fe6a7406cee64f967031e570b (patch)
tree7c73cd44211296522ab4d1048de8e91cd70d4282 /Lib/string.py
parent5ab60e4aaeca785f6a548344bba2a92c89ff038a (diff)
downloadcpython-e4747ec4e0c4a84fe6a7406cee64f967031e570b.tar.gz
Invalid patterns to substitute and safe_substitute would crash since pattern
is not a local variable. Add a test case.
Diffstat (limited to 'Lib/string.py')
-rw-r--r--Lib/string.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/string.py b/Lib/string.py
index 7371c915a1..e10087eb2a 100644
--- a/Lib/string.py
+++ b/Lib/string.py
@@ -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)