[pypy-svn] r43302 - pypy/branch/pypy-string-formatting/objspace/std

arigo at codespeak.net arigo at codespeak.net
Sat May 12 18:12:32 CEST 2007


Author: arigo
Date: Sat May 12 18:12:31 2007
New Revision: 43302

Modified:
   pypy/branch/pypy-string-formatting/objspace/std/formatting.py
Log:
Translation fixes.


Modified: pypy/branch/pypy-string-formatting/objspace/std/formatting.py
==============================================================================
--- pypy/branch/pypy-string-formatting/objspace/std/formatting.py	(original)
+++ pypy/branch/pypy-string-formatting/objspace/std/formatting.py	Sat May 12 18:12:31 2007
@@ -196,7 +196,8 @@
             else:
                 self.prec = -1
 
-            if self.peekchr() in 'hlL':
+            c = self.peekchr()
+            if c == 'h' or c == 'l' or c == 'L':
                 self.forward()
 
             return w_value
@@ -231,8 +232,10 @@
                 w_value = self.nextinputvalue()
                 return space.int_w(maybe_int(space, w_value))
             result = 0
-            while '0' <= c <= '9':
+            while True:
                 n = ord(c) - ord('0')
+                if not (0 <= n < 10):
+                    break
                 try:
                     result = ovfcheck(ovfcheck(result * 10) + n)
                 except OverflowError:
@@ -286,8 +289,7 @@
 
         def unknown_fmtchar(self):
             space = self.space
-            self.fmtpos -= 1
-            c = self.peekchr()
+            c = self.fmt[self.fmtpos - 1]
             if do_unicode:
                 w_defaultencoding = space.call_function(
                     space.sys.get('getdefaultencoding'))
@@ -304,8 +306,9 @@
 
         def std_wp(self, r):
             length = len(r)
-            if self.prec >= 0 and self.prec < length:
-                length = self.prec   # ignore the end of the string if too long
+            prec = self.prec
+            if prec >= 0 and prec < length:
+                length = prec   # ignore the end of the string if too long
             result = self.result
             padding = self.width - length
             if not self.f_ljust:


More information about the pypy-svn mailing list