diff options
Diffstat (limited to 'Lib/string.py')
-rw-r--r-- | Lib/string.py | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/Lib/string.py b/Lib/string.py index 89287c4c0a..7298c89087 100644 --- a/Lib/string.py +++ b/Lib/string.py @@ -116,10 +116,7 @@ class Template(metaclass=_TemplateMetaclass): # Check the most common path first. named = mo.group('named') or mo.group('braced') if named is not None: - 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 str(mapping[named]) if mo.group('escaped') is not None: return self.delimiter if mo.group('invalid') is not None: @@ -146,9 +143,7 @@ class Template(metaclass=_TemplateMetaclass): named = mo.group('named') or mo.group('braced') if named is not None: 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 str(mapping[named]) except KeyError: return mo.group() if mo.group('escaped') is not None: |