[Python-checkins] r51172 - in python/trunk: Lib/test/test_builtin.py Objects/typeobject.c

armin.rigo python-checkins at python.org
Wed Aug 9 16:55:27 CEST 2006


Author: armin.rigo
Date: Wed Aug  9 16:55:26 2006
New Revision: 51172

Modified:
   python/trunk/Lib/test/test_builtin.py
   python/trunk/Objects/typeobject.c
Log:
Fix and test for an infinite C recursion.


Modified: python/trunk/Lib/test/test_builtin.py
==============================================================================
--- python/trunk/Lib/test/test_builtin.py	(original)
+++ python/trunk/Lib/test/test_builtin.py	Wed Aug  9 16:55:26 2006
@@ -649,6 +649,10 @@
             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')

Modified: python/trunk/Objects/typeobject.c
==============================================================================
--- python/trunk/Objects/typeobject.c	(original)
+++ python/trunk/Objects/typeobject.c	Wed Aug  9 16:55:26 2006
@@ -4560,7 +4560,7 @@
 		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);


More information about the Python-checkins mailing list