Commits

Manuel Jacob  committed a8df5c2

Raise the right error if int() is called with a base that doesn't fit into the machine's long int type.

  • Participants
  • Parent commits 2fb15b5
  • Branches py3k

Comments (0)

Files changed (2)

File pypy/objspace/std/longtype.py

             bigint = space.bigint_w(w_obj)
             return newbigint(space, w_longtype, bigint)
     else:
-        base = space.int_w(w_base)
+        try:
+            base = space.int_w(w_base)
+        except OperationError, e:
+            if not e.match(space, space.w_OverflowError):
+                raise
+            base = 37 # this raises the right error in string_to_bigint()
 
         if space.isinstance_w(w_value, space.w_unicode):
             from pypy.objspace.std.unicodeobject import unicode_to_decimal_w

File pypy/objspace/std/test/test_longobject.py

             assert 'hello àèìò' in e.message
         else:
             assert False, 'did not raise'
+
+    def test_base_overflow(self):
+        raises(ValueError, int, '42', 2**63)