summaryrefslogtreecommitdiffstats
path: root/Objects/stringlib
diff options
context:
space:
mode:
authorEric Smith <eric@trueblade.com>2008-07-17 17:48:39 (GMT)
committerEric Smith <eric@trueblade.com>2008-07-17 17:48:39 (GMT)
commit454816d8bdd6ec9bb986aa31760518e622dc1ea7 (patch)
tree3ee9ce763f7c0545f625b9de580ca98722cb7080 /Objects/stringlib
parent4347c44f1834887602402b7eec0e82214bd6bd1d (diff)
downloadcpython-454816d8bdd6ec9bb986aa31760518e622dc1ea7.zip
cpython-454816d8bdd6ec9bb986aa31760518e622dc1ea7.tar.gz
cpython-454816d8bdd6ec9bb986aa31760518e622dc1ea7.tar.bz2
Issue 3382: Make '%F' and float.__format__('F') convert results to upper case.
Diffstat (limited to 'Objects/stringlib')
-rw-r--r--Objects/stringlib/formatter.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/Objects/stringlib/formatter.h b/Objects/stringlib/formatter.h
index b964435..d8cb171 100644
--- a/Objects/stringlib/formatter.h
+++ b/Objects/stringlib/formatter.h
@@ -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"