summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
authorEric Smith <eric@trueblade.com>2008-07-17 18:30:48 (GMT)
committerEric Smith <eric@trueblade.com>2008-07-17 18:30:48 (GMT)
commita4fac36eb3ee70529482d43d2a484d5ff5d18398 (patch)
treef28ae6605017ff42d83cdf78978391b4c7237079 /Objects/unicodeobject.c
parentddc5669fd90135ba345a9f1a98a11c67a97f833e (diff)
downloadcpython-a4fac36eb3ee70529482d43d2a484d5ff5d18398.zip
cpython-a4fac36eb3ee70529482d43d2a484d5ff5d18398.tar.gz
cpython-a4fac36eb3ee70529482d43d2a484d5ff5d18398.tar.bz2
Merged revisions 65069 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r65069 | eric.smith | 2008-07-17 13:48:39 -0400 (Thu, 17 Jul 2008) | 1 line Issue 3382: Make '%F' and float.__format__('F') convert results to upper case. ........
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r--Objects/unicodeobject.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index b0b525a..85d838c 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -8588,8 +8588,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:
@@ -8608,7 +8612,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;
@@ -9091,8 +9096,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);