diff -r 1b2134a78c17 Lib/test/test_int.py --- a/Lib/test/test_int.py Fri Dec 28 10:09:54 2012 +0200 +++ b/Lib/test/test_int.py Fri Dec 28 10:24:43 2012 +0000 @@ -260,6 +260,23 @@ with self.assertRaises(TypeError): int('0', 5.0) + def test_int_base_indexable(self): + class MyIndexable(object): + def __init__(self, value): + self.value = value + def __index__(self): + return self.value + + # Check out of range bases. + for base in 2**100, -2**100, 1, 37: + with self.assertRaises(ValueError): + int('43', base) + + # Check in-range bases. + self.assertEqual(int('101', base=MyIndexable(2)), 5) + self.assertEqual(int('101', base=MyIndexable(10)), 101) + self.assertEqual(int('101', base=MyIndexable(36)), 1 + 36**2) + def test_non_numeric_input_types(self): # Test possible non-numeric types for the argument x, including # subclasses of the explicitly documented accepted types. diff -r 1b2134a78c17 Objects/longobject.c --- a/Objects/longobject.c Fri Dec 28 10:09:54 2012 +0200 +++ b/Objects/longobject.c Fri Dec 28 10:24:43 2012 +0000 @@ -4265,11 +4265,6 @@ } if (obase == NULL) return PyNumber_Long(x); - if (!PyLong_Check(obase)) { - PyErr_SetString(PyExc_TypeError, - "int() base must be an integer."); - return NULL; - } base = PyNumber_AsSsize_t(obase, NULL); if (base == -1 && PyErr_Occurred())