From e56bf97ef4283a877c459390516bb7385e8e4ec4 Mon Sep 17 00:00:00 2001 From: R David Murray Date: Sun, 19 Aug 2012 17:26:34 -0400 Subject: #13579: teach string.Formatter about 'a'. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch by Francisco Martín Brugué. --- Lib/string.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Lib/string.py') diff --git a/Lib/string.py b/Lib/string.py index ef0334c472f..0f4ede23e14 100644 --- a/Lib/string.py +++ b/Lib/string.py @@ -236,12 +236,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)) -- cgit v1.2.3