mirror of
https://github.com/python/cpython.git
synced 2025-07-30 06:34:15 +00:00
Issue 3382: Make '%F' and float.__format__('F') convert results to upper case.
This commit is contained in:
parent
4347c44f18
commit
454816d8bd
8 changed files with 53 additions and 23 deletions
|
@ -8191,8 +8191,12 @@ formatfloat(Py_UNICODE *buf,
|
|||
return -1;
|
||||
if (prec < 0)
|
||||
prec = 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';
|
||||
}
|
||||
/* Worst case length calc to ensure no buffer overrun:
|
||||
|
||||
'g' formats:
|
||||
|
@ -8211,7 +8215,8 @@ formatfloat(Py_UNICODE *buf,
|
|||
*/
|
||||
if (((type == 'g' || type == 'G') &&
|
||||
buflen <= (size_t)10 + (size_t)prec) ||
|
||||
(type == 'f' && buflen <= (size_t)53 + (size_t)prec)) {
|
||||
((type == 'f' || type == 'F') &&
|
||||
buflen <= (size_t)53 + (size_t)prec)) {
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"formatted float is too long (precision too large?)");
|
||||
return -1;
|
||||
|
@ -8704,8 +8709,6 @@ PyObject *PyUnicode_Format(PyObject *format,
|
|||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue