mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Issue #24309: Removed Python 2 idioms.
This commit is contained in:
parent
bffc2b4ab7
commit
6e6883f11a
1 changed files with 2 additions and 7 deletions
|
@ -112,10 +112,7 @@ class Template(metaclass=_TemplateMetaclass):
|
||||||
# Check the most common path first.
|
# Check the most common path first.
|
||||||
named = mo.group('named') or mo.group('braced')
|
named = mo.group('named') or mo.group('braced')
|
||||||
if named is not None:
|
if named is not None:
|
||||||
val = mapping[named]
|
return str(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,)
|
|
||||||
if mo.group('escaped') is not None:
|
if mo.group('escaped') is not None:
|
||||||
return self.delimiter
|
return self.delimiter
|
||||||
if mo.group('invalid') is not None:
|
if mo.group('invalid') is not None:
|
||||||
|
@ -142,9 +139,7 @@ class Template(metaclass=_TemplateMetaclass):
|
||||||
named = mo.group('named') or mo.group('braced')
|
named = mo.group('named') or mo.group('braced')
|
||||||
if named is not None:
|
if named is not None:
|
||||||
try:
|
try:
|
||||||
# We use this idiom instead of str() because the latter
|
return str(mapping[named])
|
||||||
# will fail if val is a Unicode containing non-ASCII
|
|
||||||
return '%s' % (mapping[named],)
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return mo.group()
|
return mo.group()
|
||||||
if mo.group('escaped') is not None:
|
if mo.group('escaped') is not None:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue