summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2006-07-03 13:47:40 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2006-07-03 13:47:40 (GMT)
commitd5cfa5491a7a7c23fa31bf2262d00fcaf4b7474d (patch)
tree9ae965d962e4328564b993839bfaa4c87cf98a4e
parentede77f5373e38ce1befc02858dcbcff8214c061b (diff)
downloadcpython-d5cfa5491a7a7c23fa31bf2262d00fcaf4b7474d.zip
cpython-d5cfa5491a7a7c23fa31bf2262d00fcaf4b7474d.tar.gz
cpython-d5cfa5491a7a7c23fa31bf2262d00fcaf4b7474d.tar.bz2
Put method-wrappers into trashcan. Fixes #927248.
-rw-r--r--Lib/test/test_descr.py8
-rw-r--r--Misc/NEWS3
-rw-r--r--Objects/descrobject.c4
3 files changed, 14 insertions, 1 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index d9249b6..6484ef1 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -3966,6 +3966,13 @@ def weakref_segfault():
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 notimplemented():
def test_main():
weakref_segfault() # Must be first, somehow
+ wrapper_segfault()
do_this_first()
class_docstrings()
lists()
diff --git a/Misc/NEWS b/Misc/NEWS
index 11add31..34795a4 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 2.5 beta 2?
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().
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
index 606ef05..51676f6 100644
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -892,10 +892,12 @@ typedef struct {
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