summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r--Objects/unicodeobject.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 85d838c..b0b525a 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -8588,12 +8588,8 @@ formatfloat(Py_UNICODE *buf,
return -1;
if (prec < 0)
prec = 6;
- if ((type == 'f' || type == 'F') && (fabs(x) / 1e25) >= 1e25) {
- if (type == 'f')
- type = 'g';
- else
- type = 'G';
- }
+ if (type == 'f' && (fabs(x) / 1e25) >= 1e25)
+ type = 'g';
/* Worst case length calc to ensure no buffer overrun:
'g' formats:
@@ -8612,8 +8608,7 @@ formatfloat(Py_UNICODE *buf,
*/
if (((type == 'g' || type == 'G') &&
buflen <= (size_t)10 + (size_t)prec) ||
- ((type == 'f' || type == 'F') &&
- buflen <= (size_t)53 + (size_t)prec)) {
+ (type == 'f' && buflen <= (size_t)53 + (size_t)prec)) {
PyErr_SetString(PyExc_OverflowError,
"formatted float is too long (precision too large?)");
return -1;
@@ -9096,6 +9091,8 @@ 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);