Merge #13579: teach string.Formatter about 'a'.

Patch by Francisco Martín Brugué.
This commit is contained in:
R David Murray 2012-08-19 17:45:40 -04:00
commit 749bd42072
4 changed files with 20 additions and 9 deletions

View file

@ -220,12 +220,14 @@ class Formatter:
def convert_field(self, value, conversion):
# do any conversion on the resulting object
if conversion == 'r':
return repr(value)
if conversion is None:
return value
elif conversion == 's':
return str(value)
elif conversion is None:
return value
elif conversion == 'r':
return repr(value)
elif conversion == 'a':
return ascii(value)
raise ValueError("Unknown conversion specifier {0!s}".format(conversion))