Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r48227:ff2cfafa5e63
Date: 2011-10-19 13:25 +0200
http://bitbucket.org/pypy/pypy/changeset/ff2cfafa5e63/

Log:    Issue916: test and fix by dhx.

diff --git a/pypy/objspace/std/strutil.py b/pypy/objspace/std/strutil.py
--- a/pypy/objspace/std/strutil.py
+++ b/pypy/objspace/std/strutil.py
@@ -35,7 +35,7 @@
 
     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
@@ -47,7 +47,8 @@
         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
diff --git a/pypy/objspace/std/test/test_strutil.py 
b/pypy/objspace/std/test/test_strutil.py
--- a/pypy/objspace/std/test/test_strutil.py
+++ b/pypy/objspace/std/test/test_strutil.py
@@ -89,6 +89,8 @@
 
         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
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to