summaryrefslogtreecommitdiff
path: root/Lib/string.py
diff options
context:
space:
mode:
authorThomas Wouters <thomas@python.org>2006-07-05 11:03:49 +0000
committerThomas Wouters <thomas@python.org>2006-07-05 11:03:49 +0000
commit285c3c551bcf23e2f86dca677311679bbb602c6e (patch)
tree259e64aae9cf961a339b200b7ce8e5bd0ce5e93d /Lib/string.py
parentd562cca186b3af9619ea91efea7b1aa51bee6aa1 (diff)
downloadcpython-285c3c551bcf23e2f86dca677311679bbb602c6e.tar.gz
Fix bug in passing tuples to string.Template. All other values (with working
str() or repr()) would work, just not multi-value tuples. Probably not a backport candidate, since it changes the behaviour of passing a single-element tuple: >>> string.Template("$foo").substitute(dict(foo=(1,))) '(1,)' versus '1'
Diffstat (limited to 'Lib/string.py')
-rw-r--r--Lib/string.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/string.py b/Lib/string.py
index ba85a49835..a5837e94b8 100644
--- a/Lib/string.py
+++ b/Lib/string.py
@@ -161,7 +161,7 @@ class Template:
val = mapping[named]
# We use this idiom instead of str() because the latter will
# fail if val is a Unicode containing non-ASCII characters.
- return '%s' % val
+ return '%s' % (val,)
if mo.group('escaped') is not None:
return self.delimiter
if mo.group('invalid') is not None:
@@ -186,13 +186,13 @@ class Template:
try:
# We use this idiom instead of str() because the latter
# will fail if val is a Unicode containing non-ASCII
- return '%s' % mapping[named]
+ return '%s' % (mapping[named],)
except KeyError:
return self.delimiter + named
braced = mo.group('braced')
if braced is not None:
try:
- return '%s' % mapping[braced]
+ return '%s' % (mapping[braced],)
except KeyError:
return self.delimiter + '{' + braced + '}'
if mo.group('escaped') is not None: