Commit 51fc8c45 authored by Armin Rigo's avatar Armin Rigo

Fix and test for an infinite C recursion.

parent 98c04804
...@@ -649,6 +649,10 @@ class BuiltinTest(unittest.TestCase): ...@@ -649,6 +649,10 @@ class BuiltinTest(unittest.TestCase):
def __hash__(self): def __hash__(self):
return 2**100 return 2**100
self.assertEquals(type(hash(Y())), int) 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): def test_hex(self):
self.assertEqual(hex(16), '0x10') self.assertEqual(hex(16), '0x10')
......
...@@ -4560,7 +4560,7 @@ slot_tp_hash(PyObject *self) ...@@ -4560,7 +4560,7 @@ slot_tp_hash(PyObject *self)
if (res == NULL) if (res == NULL)
return -1; return -1;
if (PyLong_Check(res)) if (PyLong_Check(res))
h = res->ob_type->tp_hash(res); h = PyLong_Type.tp_hash(res);
else else
h = PyInt_AsLong(res); h = PyInt_AsLong(res);
Py_DECREF(res); Py_DECREF(res);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment