From: Raymond Hettinger Date: Wed, 27 Aug 2003 05:08:19 +0000 (+0000) Subject: SF bug #795506: Wrong handling of string format code for float values. X-Git-Tag: v2.3.1~129 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=eb85c6617bb868ee1efd0851bc6bd3bd1adcda8a;p=thirdparty%2FPython%2Fcpython.git SF bug #795506: Wrong handling of string format code for float values. Added missing support for '%F' as had been documented. --- diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py index 7c98a3bb8c84..af171d08ab3f 100644 --- a/Lib/test/string_tests.py +++ b/Lib/test/string_tests.py @@ -550,6 +550,7 @@ class MixinStrUnicodeUserStringTest: self.checkequal(' 42', '%3ld', '__mod__', 42) self.checkequal('0042.00', '%07.2f', '__mod__', 42) + self.checkequal('0042.00', '%07.2F', '__mod__', 42) self.checkraises(TypeError, 'abc', '__mod__') self.checkraises(TypeError, '%(foo)s', '__mod__', 42) diff --git a/Misc/NEWS b/Misc/NEWS index aec99857d19a..9c6152bb2e5e 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,9 @@ What's New in Python 2.3.1? Core and builtins ----------------- +- Bug #795506: The % formatting operator did not support '%F' as + had been documented. + - Bug #775985: Only set stdout.encoding if a codec is available. Extension modules diff --git a/Objects/stringobject.c b/Objects/stringobject.c index 31aeaa7c7416..04c9c9887a2b 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -3921,8 +3921,11 @@ PyString_Format(PyObject *format, PyObject *args) case 'e': case 'E': case 'f': + case 'F': case 'g': case 'G': + if (c == 'F') + c = 'f'; pbuf = formatbuf; len = formatfloat(pbuf, sizeof(formatbuf), flags, prec, c, v); diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 163976e952b7..7ba9547b1f74 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -6540,8 +6540,11 @@ PyObject *PyUnicode_Format(PyObject *format, case 'e': case 'E': case 'f': + case 'F': case 'g': case 'G': + if (c == 'F') + c = 'f'; pbuf = formatbuf; len = formatfloat(pbuf, sizeof(formatbuf)/sizeof(Py_UNICODE), flags, prec, c, v);