diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2011-09-12 21:09:12 +0200 |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2011-09-12 21:09:12 +0200 |
commit | 65604b51e0da56e244a2266482687959d310b08d (patch) | |
tree | 42151d2da7b1baeb4357e963759ca7d62664ed25 | |
parent | aa2b442bdccf68c191a0023084b1160804fb5e4c (diff) | |
parent | bbe46d63ee9b624c011b4fe50978e2e7fa7cf82e (diff) | |
download | cpython-git-65604b51e0da56e244a2266482687959d310b08d.tar.gz |
Merge 3.2: Issue #12483: ctypes: Fix a crash when the destruction of a callback
object triggers the garbage collector.
-rw-r--r-- | Lib/ctypes/test/test_callbacks.py | 8 | ||||
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Modules/_ctypes/callbacks.c | 1 |
3 files changed, 12 insertions, 0 deletions
diff --git a/Lib/ctypes/test/test_callbacks.py b/Lib/ctypes/test/test_callbacks.py index 8801ccd106..c7207eab9d 100644 --- a/Lib/ctypes/test/test_callbacks.py +++ b/Lib/ctypes/test/test_callbacks.py @@ -134,6 +134,14 @@ class Callbacks(unittest.TestCase): if isinstance(x, X)] self.assertEqual(len(live), 0) + def test_issue12483(self): + import gc + class Nasty: + def __del__(self): + gc.collect() + CFUNCTYPE(None)(lambda x=Nasty(): None) + + try: WINFUNCTYPE except NameError: @@ -1274,6 +1274,9 @@ Tools/Demos Extension Modules ----------------- +- Issue #12483: ctypes: Fix a crash when the destruction of a callback + object triggers the garbage collector. + - Issue #12950: Fix passing file descriptors in multiprocessing, under OpenIndiana/Illumos. diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c index d23509fbe2..34c46ad7a7 100644 --- a/Modules/_ctypes/callbacks.c +++ b/Modules/_ctypes/callbacks.c @@ -13,6 +13,7 @@ static void CThunkObject_dealloc(PyObject *_self) { CThunkObject *self = (CThunkObject *)_self; + PyObject_GC_UnTrack(self); Py_XDECREF(self->converters); Py_XDECREF(self->callable); Py_XDECREF(self->restype); |