[Python-checkins] r46807 - in python/branches/release24-maint: Lib/test/test_descr.py Misc/NEWS Objects/abstract.c

brett.cannon python-checkins at python.org
Sat Jun 10 00:38:30 CEST 2006


Author: brett.cannon
Date: Sat Jun 10 00:38:29 2006
New Revision: 46807
Modified:
 python/branches/release24-maint/Lib/test/test_descr.py
 python/branches/release24-maint/Misc/NEWS
 python/branches/release24-maint/Objects/abstract.c
Log:
Backport of fix of bug #532646 for new-style classes.
Modified: python/branches/release24-maint/Lib/test/test_descr.py
==============================================================================
--- python/branches/release24-maint/Lib/test/test_descr.py	(original)
+++ python/branches/release24-maint/Lib/test/test_descr.py	Sat Jun 10 00:38:29 2006
@@ -3116,6 +3116,21 @@
 list.__init__(a, sequence=[0, 1, 2])
 vereq(a, [0, 1, 2])
 
+def recursive__call__():
+ if verbose: print ("Testing recursive __call__() by setting to instance of "
+ "class ...")
+ class A(object):
+ pass
+
+ A.__call__ = A()
+ try:
+ A()()
+ except RuntimeError:
+ pass
+ else:
+ raise TestFailed("Recursion limit should have been reached for "
+ "__call__()")
+
 def delhook():
 if verbose: print "Testing __del__ hook..."
 log = []
@@ -4118,6 +4133,7 @@
 buffer_inherit()
 str_of_str_subclass()
 kwdargs()
+ recursive__call__()
 delhook()
 hashinherit()
 strops()
Modified: python/branches/release24-maint/Misc/NEWS
==============================================================================
--- python/branches/release24-maint/Misc/NEWS	(original)
+++ python/branches/release24-maint/Misc/NEWS	Sat Jun 10 00:38:29 2006
@@ -12,6 +12,10 @@
 Core and builtins
 -----------------
 
+- Bug #532646: The object set to the __call__ attribute has its own __call__
+ attribute checked; this continues until the attribute can no longer be found
+ or segfaulting. Recursion limit is now followed.
+
 - Bug #1454485: Don't crash on Unicode characters <0.
 
 - Patch #1488312, Fix memory alignment problem on SPARC in unicode
Modified: python/branches/release24-maint/Objects/abstract.c
==============================================================================
--- python/branches/release24-maint/Objects/abstract.c	(original)
+++ python/branches/release24-maint/Objects/abstract.c	Sat Jun 10 00:38:29 2006
@@ -1792,7 +1792,10 @@
 ternaryfunc call;
 
 	if ((call = func->ob_type->tp_call) != NULL) {
+		if (Py_EnterRecursiveCall(" in __call__"))
+			return NULL;
 		PyObject *result = (*call)(func, arg, kw);
+		Py_LeaveRecursiveCall();
 		if (result == NULL && !PyErr_Occurred())
 			PyErr_SetString(
 				PyExc_SystemError,


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /