diff options
author | Maciej Fijalkowski <fijall@gmail.com> | 2010-03-30 03:27:01 +0000 |
---|---|---|
committer | Maciej Fijalkowski <fijall@gmail.com> | 2010-03-30 03:27:01 +0000 |
commit | 1067f6230f1117cfa05b05ee49c3147bc9d3b44e (patch) | |
tree | e9a6e22c705f50f664de2ce4fd556e2694f564f0 /pypy/module/_weakref | |
parent | store method cache state on a custom object (diff) | |
download | pypy-1067f6230f1117cfa05b05ee49c3147bc9d3b44e.tar.gz pypy-1067f6230f1117cfa05b05ee49c3147bc9d3b44e.tar.bz2 pypy-1067f6230f1117cfa05b05ee49c3147bc9d3b44e.zip |
Try to kill segfault by fighting with uncontrolled calls of app level weakref
callback in the middle of compiling assembler (it could segfault pypy other
way, but this is the observed way).
Diffstat (limited to 'pypy/module/_weakref')
-rw-r--r-- | pypy/module/_weakref/interp__weakref.py | 2 | ||||
-rw-r--r-- | pypy/module/_weakref/test/test_weakref.py | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/pypy/module/_weakref/interp__weakref.py b/pypy/module/_weakref/interp__weakref.py index 9ad2e27e68..4c8d9ef81c 100644 --- a/pypy/module/_weakref/interp__weakref.py +++ b/pypy/module/_weakref/interp__weakref.py @@ -23,7 +23,7 @@ class WeakrefLifeline(object): for i in range(len(self.refs_weak) - 1, -1, -1): w_ref = self.refs_weak[i]() if w_ref is not None: - w_ref.activate_callback() + self.space.user_del_action.register_weakref_callback(w_ref) def clear_all_weakrefs(self): """Clear all weakrefs. This is called when an app-level object has diff --git a/pypy/module/_weakref/test/test_weakref.py b/pypy/module/_weakref/test/test_weakref.py index ab2666bd13..cb7d076324 100644 --- a/pypy/module/_weakref/test/test_weakref.py +++ b/pypy/module/_weakref/test/test_weakref.py @@ -411,3 +411,15 @@ class AppTestProxy(object): a = A() assert _weakref.ref(a) == a + + def test_callback_raises(self): + import _weakref, gc + class A(object): + pass + a1 = A() + def callback(ref): + explode + ref1 = _weakref.ref(a1, callback) + del a1 + gc.collect() + assert ref1() is None |