Commits

Armin Rigo committed ff2cfaf

Issue916: test and fix by dhx.

Comments (0)

Files changed (2)

pypy/objspace/std/strutil.py

 
     def error(self):
         raise ParseStringError("invalid literal for %s() with base %d: '%s'" %
-                               (self.fname, self.base, self.literal))
+                               (self.fname, self.original_base, self.literal))
 
     def __init__(self, s, literal, base, fname):
         self.literal = literal
         elif s.startswith('+'):
             s = strip_spaces(s[1:])
         self.sign = sign
-        
+        self.original_base = base
+
         if base == 0:
             if s.startswith('0x') or s.startswith('0X'):
                 base = 16

pypy/objspace/std/test/test_strutil.py

 
         exc = raises(ParseStringError, string_to_int, '')
         assert exc.value.msg == "invalid literal for int() with base 10: ''"
+        exc = raises(ParseStringError, string_to_int, '', 0)
+        assert exc.value.msg == "invalid literal for int() with base 0: ''"
 
     def test_string_to_int_overflow(self):
         import sys