]> granicus.if.org Git - python/commitdiff
Issue #24309: Removed Python 2 idioms.
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 28 May 2015 17:45:29 +0000 (20:45 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Thu, 28 May 2015 17:45:29 +0000 (20:45 +0300)
Lib/string.py

index f3365c67fb4fb5f36aee60a9cf85494f31a0d2eb..e7b692d7f79f15ee2ee38369a5d85db3260f7383 100644 (file)
@@ -112,10 +112,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:
@@ -142,9 +139,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: