[Jython-checkins] jython: Fix Python issue 3382: Make '%F' and float.__format__('F') convert results to

nicholas.riley jython-checkins at python.org
Wed Mar 21 21:20:50 CET 2012


http://hg.python.org/jython/rev/74cae35a68b6
changeset:   6459:74cae35a68b6
user:        Nicholas Riley <njriley at illinois.edu>
date:        Wed Mar 21 16:20:19 2012 -0400
summary:
  Fix Python issue 3382: Make '%F' and float.__format__('F') convert results to upper case.

http://bugs.python.org/issue3382

Also implement uppercasing for %E and %G, which are fine in Python 2.5 but not in Jython 2.5.

Note that the latter part of the issue is not fixed yet because __format__ isn't implemented for floats (see http://bugs.jython.org/issue1718).

files:
  src/org/python/core/PyString.java |  6 ++++++
  1 files changed, 6 insertions(+), 0 deletions(-)


diff --git a/src/org/python/core/PyString.java b/src/org/python/core/PyString.java
--- a/src/org/python/core/PyString.java
+++ b/src/org/python/core/PyString.java
@@ -3177,10 +3177,14 @@
             case 'e':
             case 'E':
                 string = formatFloatExponential(arg, c, false);
+                if (c == 'E')
+                    string = string.toUpperCase();
                 break;
             case 'f':
             case 'F':
                 string = formatFloatDecimal(asDouble(arg), false);
+                if (c == 'F')
+                    string = string.toUpperCase();
                 break;
             case 'g':
             case 'G':
@@ -3218,6 +3222,8 @@
                     precision--;
                     string = formatFloatExponential(arg, (char)(c-2), !altFlag);
                 }
+                if (c == 'G')
+                    string = string.toUpperCase();
                 break;
             case 'c':
                 fill = ' ';

-- 
Repository URL: http://hg.python.org/jython


More information about the Jython-checkins mailing list