[pypy-svn] r80011 - in pypy/branch/fast-forward/pypy/objspace/std: . test

afa at codespeak.net afa at codespeak.net
Sun Dec 12 23:07:46 CET 2010


Author: afa
Date: Sun Dec 12 23:07:45 2010
New Revision: 80011

Modified:
   pypy/branch/fast-forward/pypy/objspace/std/strutil.py
   pypy/branch/fast-forward/pypy/objspace/std/test/test_strutil.py
Log:
Update error message to better match CPython


Modified: pypy/branch/fast-forward/pypy/objspace/std/strutil.py
==============================================================================
--- pypy/branch/fast-forward/pypy/objspace/std/strutil.py	(original)
+++ pypy/branch/fast-forward/pypy/objspace/std/strutil.py	Sun Dec 12 23:07:45 2010
@@ -34,11 +34,9 @@
 class NumberStringParser:
 
     def error(self):
-        if self.literal:
-            raise ParseStringError, 'invalid literal for %s(): %s' % (self.fname, self.literal)
-        else:
-            raise ParseStringError, 'empty string for %s()' % (self.fname,)        
-        
+        raise ParseStringError("invalid literal for %s() with base %d: '%s'" %
+                               (self.fname, self.base, self.literal))
+
     def __init__(self, s, literal, base, fname):
         self.literal = literal
         self.fname = fname

Modified: pypy/branch/fast-forward/pypy/objspace/std/test/test_strutil.py
==============================================================================
--- pypy/branch/fast-forward/pypy/objspace/std/test/test_strutil.py	(original)
+++ pypy/branch/fast-forward/pypy/objspace/std/test/test_strutil.py	Sun Dec 12 23:07:45 2010
@@ -87,6 +87,9 @@
         raises(ParseStringError, string_to_int, '0x', 16)
         raises(ParseStringError, string_to_int, '-0x', 16)
 
+        exc = raises(ParseStringError, string_to_int, '')
+        assert exc.value.msg == "invalid literal for int() with base 10: ''"
+
     def test_string_to_int_overflow(self):
         import sys
         space = self.space



More information about the Pypy-commit mailing list