self.assertRaises(ValueError, int, "0b", 2)
self.assertRaises(ValueError, int, "0b", 0)
+ # Bug #3236: Return small longs from PyLong_FromString
+ self.assert_(int("10") is 10)
+ self.assert_(int("-1") is -1)
# SF bug 1334662: int(string, base) wrong answers
# Various representations of 2**32 evaluated to 0
goto onError;
if (pend)
*pend = str;
+ long_normalize(z);
+ if (ABS(Py_SIZE(z)) <= 1) {
+ long res = MEDIUM_VALUE(z);
+ if (-NSMALLPOSINTS <= res && res <= NSMALLPOSINTS) {
+ Py_DECREF(z);
+ return PyLong_FromLong(res);
+ }
+ }
return (PyObject *) z;
onError: