Issue 3382: Make '%F' and float.__format__('F') convert results to upper case.

This commit is contained in:
Eric Smith 2008-07-17 17:48:39 +00:00
parent 4347c44f18
commit 454816d8bd
8 changed files with 53 additions and 23 deletions

View file

@ -741,10 +741,6 @@ format_float_internal(PyObject *value,
/* first, do the conversion as 8-bit chars, using the platform's
snprintf. then, if needed, convert to unicode. */
/* 'F' is the same as 'f', per the PEP */
if (type == 'F')
type = 'f';
x = PyFloat_AsDouble(value);
if (x == -1.0 && PyErr_Occurred())
@ -758,8 +754,12 @@ format_float_internal(PyObject *value,
if (precision < 0)
precision = 6;
if (type == 'f' && (fabs(x) / 1e25) >= 1e25)
type = 'g';
if ((type == 'f' || type == 'F') && (fabs(x) / 1e25) >= 1e25) {
if (type == 'f')
type = 'g';
else
type = 'G';
}
/* cast "type", because if we're in unicode we need to pass a
8-bit char. this is safe, because we've restricted what "type"