From 51fc8c456e9bbb97f42c6990e40019cd4a5eb615 Mon Sep 17 00:00:00 2001 From: Armin Rigo Date: Wed, 9 Aug 2006 14:55:26 +0000 Subject: Fix and test for an infinite C recursion. --- Lib/test/test_builtin.py | 4 ++++ Objects/typeobject.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index 26bfe87..ca7a8f3 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -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') diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 652009b..485d2bb 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -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); -- cgit v0.12