[Python-checkins] r47218 - in python/trunk: Lib/test/test_descr.py Misc/NEWS Objects/descrobject.c

martin.v.loewis python-checkins at python.org
Mon Jul 3 15:47:41 CEST 2006


Author: martin.v.loewis
Date: Mon Jul  3 15:47:40 2006
New Revision: 47218

Modified:
   python/trunk/Lib/test/test_descr.py
   python/trunk/Misc/NEWS
   python/trunk/Objects/descrobject.c
Log:
Put method-wrappers into trashcan. Fixes #927248.


Modified: python/trunk/Lib/test/test_descr.py
==============================================================================
--- python/trunk/Lib/test/test_descr.py	(original)
+++ python/trunk/Lib/test/test_descr.py	Mon Jul  3 15:47:40 2006
@@ -3966,6 +3966,13 @@
     o.whatever = Provoker(o)
     del o
 
+def wrapper_segfault():
+    # SF 927248: deeply nested wrappers could cause stack overflow
+    f = lambda:None
+    for i in xrange(1000000):
+        f = f.__call__
+    f = None
+
 # Fix SF #762455, segfault when sys.stdout is changed in getattr
 def filefault():
     if verbose:
@@ -4121,6 +4128,7 @@
 
 def test_main():
     weakref_segfault() # Must be first, somehow
+    wrapper_segfault()
     do_this_first()
     class_docstrings()
     lists()

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Mon Jul  3 15:47:40 2006
@@ -12,6 +12,9 @@
 Core and builtins
 -----------------
 
+- Bug #927248: Recursive method-wrapper objects can now safely
+  be released.
+
 - Bug #1417699: Reject locale-specific decimal point in float()
   and atof().
 

Modified: python/trunk/Objects/descrobject.c
==============================================================================
--- python/trunk/Objects/descrobject.c	(original)
+++ python/trunk/Objects/descrobject.c	Mon Jul  3 15:47:40 2006
@@ -892,10 +892,12 @@
 static void
 wrapper_dealloc(wrapperobject *wp)
 {
-	_PyObject_GC_UNTRACK(wp);
+	PyObject_GC_UnTrack(wp);
+	Py_TRASHCAN_SAFE_BEGIN(wp)
 	Py_XDECREF(wp->descr);
 	Py_XDECREF(wp->self);
 	PyObject_GC_Del(wp);
+	Py_TRASHCAN_SAFE_END(wp)
 }
 
 static int


More information about the Python-checkins mailing list