[pypy-commit] pypy default: Fix for 19252e1566a1

arigo noreply at buildbot.pypy.org
Fri Sep 26 08:56:59 CEST 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r73713:8cc70b841989
Date: 2014-09-26 08:56 +0200
http://bitbucket.org/pypy/pypy/changeset/8cc70b841989/

Log:	Fix for 19252e1566a1

diff --git a/pypy/objspace/std/newformat.py b/pypy/objspace/std/newformat.py
--- a/pypy/objspace/std/newformat.py
+++ b/pypy/objspace/std/newformat.py
@@ -580,11 +580,11 @@
             elif self._thousands_sep:
                 dec = "."
                 thousands = ","
-                grouping = "\3\0"
+                grouping = "\3"
             else:
                 dec = "."
                 thousands = ""
-                grouping = "\256"
+                grouping = "\xFF"    # special value to mean 'stop'
             if self.is_unicode:
                 self._loc_dec = dec.decode("ascii")
                 self._loc_thousands = thousands.decode("ascii")
@@ -677,14 +677,16 @@
             done = False
             previous = 0
             while True:
-                group = ord(grouping[grouping_state])
-                if group > 0:
-                    if group == 256:
+                if grouping_state >= len(grouping):
+                    group = previous     # end of string
+                else:
+                    # else, get the next value from the string
+                    group = ord(grouping[grouping_state])
+                    if group == 0xFF:    # special value to mean 'stop'
                         break
                     grouping_state += 1
                     previous = group
-                else:
-                    group = previous
+                #
                 final_grouping = min(group, max(left, max(min_width, 1)))
                 n_zeros = max(0, final_grouping - left)
                 n_chars = max(0, min(left, final_grouping))


More information about the pypy-commit mailing list