Skip to content

Commit 6e6883f

Browse files
Issue #24309: Removed Python 2 idioms.
1 parent bffc2b4 commit 6e6883f

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

Lib/string.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,7 @@ def convert(mo):
112112
# Check the most common path first.
113113
named = mo.group('named') or mo.group('braced')
114114
if named is not None:
115-
val = mapping[named]
116-
# We use this idiom instead of str() because the latter will
117-
# fail if val is a Unicode containing non-ASCII characters.
118-
return '%s' % (val,)
115+
return str(mapping[named])
119116
if mo.group('escaped') is not None:
120117
return self.delimiter
121118
if mo.group('invalid') is not None:
@@ -142,9 +139,7 @@ def convert(mo):
142139
named = mo.group('named') or mo.group('braced')
143140
if named is not None:
144141
try:
145-
# We use this idiom instead of str() because the latter
146-
# will fail if val is a Unicode containing non-ASCII
147-
return '%s' % (mapping[named],)
142+
return str(mapping[named])
148143
except KeyError:
149144
return mo.group()
150145
if mo.group('escaped') is not None:

0 commit comments

Comments
 (0)