diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-05-28 17:45:29 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-05-28 17:45:29 (GMT) |
commit | 6e6883f11ae8d0beaed3bc32537b977236c40170 (patch) | |
tree | d7fe4155b617838f90c2256e30ebf8c4d34fa3a5 | |
parent | bffc2b4ab78ab900d75324e4b979acc252e442f2 (diff) | |
download | cpython-6e6883f11ae8d0beaed3bc32537b977236c40170.zip cpython-6e6883f11ae8d0beaed3bc32537b977236c40170.tar.gz cpython-6e6883f11ae8d0beaed3bc32537b977236c40170.tar.bz2 |
Issue #24309: Removed Python 2 idioms.
-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 f3365c6..e7b692d 100644 --- a/Lib/string.py +++ b/Lib/string.py @@ -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: |