mirror of https://github.com/python/cpython.git
SF bug #795506: Wrong handling of string format code for float values.
Adding missing support for '%F'. Will backport to 2.3.1.
This commit is contained in:
parent
063606a0d5
commit
9bfe533c69
|
@ -550,6 +550,7 @@ def test_formatting(self):
|
||||||
|
|
||||||
self.checkequal(' 42', '%3ld', '__mod__', 42)
|
self.checkequal(' 42', '%3ld', '__mod__', 42)
|
||||||
self.checkequal('0042.00', '%07.2f', '__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, 'abc', '__mod__')
|
||||||
self.checkraises(TypeError, '%(foo)s', '__mod__', 42)
|
self.checkraises(TypeError, '%(foo)s', '__mod__', 42)
|
||||||
|
|
|
@ -12,6 +12,9 @@ What's New in Python 2.4 alpha 1?
|
||||||
Core and builtins
|
Core and builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- The % formatting operator now supports '%F' which is equivalent to
|
||||||
|
'%f'. This has always been documented but never implemented.
|
||||||
|
|
||||||
- complex(obj) could leak a little memory if obj wasn't a string or
|
- complex(obj) could leak a little memory if obj wasn't a string or
|
||||||
number.
|
number.
|
||||||
|
|
||||||
|
|
|
@ -3921,8 +3921,11 @@ PyString_Format(PyObject *format, PyObject *args)
|
||||||
case 'e':
|
case 'e':
|
||||||
case 'E':
|
case 'E':
|
||||||
case 'f':
|
case 'f':
|
||||||
|
case 'F':
|
||||||
case 'g':
|
case 'g':
|
||||||
case 'G':
|
case 'G':
|
||||||
|
if (c == 'F')
|
||||||
|
c = 'f';
|
||||||
pbuf = formatbuf;
|
pbuf = formatbuf;
|
||||||
len = formatfloat(pbuf, sizeof(formatbuf),
|
len = formatfloat(pbuf, sizeof(formatbuf),
|
||||||
flags, prec, c, v);
|
flags, prec, c, v);
|
||||||
|
|
|
@ -6540,8 +6540,11 @@ PyObject *PyUnicode_Format(PyObject *format,
|
||||||
case 'e':
|
case 'e':
|
||||||
case 'E':
|
case 'E':
|
||||||
case 'f':
|
case 'f':
|
||||||
|
case 'F':
|
||||||
case 'g':
|
case 'g':
|
||||||
case 'G':
|
case 'G':
|
||||||
|
if (c == 'F')
|
||||||
|
c = 'f';
|
||||||
pbuf = formatbuf;
|
pbuf = formatbuf;
|
||||||
len = formatfloat(pbuf, sizeof(formatbuf)/sizeof(Py_UNICODE),
|
len = formatfloat(pbuf, sizeof(formatbuf)/sizeof(Py_UNICODE),
|
||||||
flags, prec, c, v);
|
flags, prec, c, v);
|
||||||
|
|
Loading…
Reference in New Issue