Fix and test for an infinite C recursion.

This commit is contained in:
Armin Rigo 2006-08-09 14:55:26 +00:00
parent 98c048041d
commit 51fc8c456e
2 changed files with 5 additions and 1 deletions

View File

@ -649,6 +649,10 @@ class BuiltinTest(unittest.TestCase):
def __hash__(self):
return 2**100
self.assertEquals(type(hash(Y())), int)
class Z(long):
def __hash__(self):
return self
self.assertEquals(hash(Z(42)), hash(42L))
def test_hex(self):
self.assertEqual(hex(16), '0x10')

View File

@ -4560,7 +4560,7 @@ slot_tp_hash(PyObject *self)
if (res == NULL)
return -1;
if (PyLong_Check(res))
h = res->ob_type->tp_hash(res);
h = PyLong_Type.tp_hash(res);
else
h = PyInt_AsLong(res);
Py_DECREF(res);