[pypy-svn] r64171 - in pypy/trunk/pypy: interpreter module/_stackless module/_stackless/test rlib
cfbolz at codespeak.net
cfbolz at codespeak.net
Thu Apr 16 16:51:39 CEST 2009
Author: cfbolz
Date: Thu Apr 16 16:51:37 2009
New Revision: 64171
Modified:
pypy/trunk/pypy/interpreter/typedef.py
pypy/trunk/pypy/module/_stackless/interp_composable_coroutine.py
pypy/trunk/pypy/module/_stackless/test/test_coroutine.py
pypy/trunk/pypy/rlib/rcoroutine.py
Log:
(pedronis, cfbolz, armin around): fix subclasses of coroutines that have a
__del__.
Modified: pypy/trunk/pypy/interpreter/typedef.py
==============================================================================
--- pypy/trunk/pypy/interpreter/typedef.py (original)
+++ pypy/trunk/pypy/interpreter/typedef.py Thu Apr 16 16:51:37 2009
@@ -133,7 +133,9 @@
def get_unique_interplevel_subclass(cls, hasdict, wants_slots, needsdel=False,
weakrefable=False):
- "NOT_RPYTHON: initialization-time only"
+ "NOT_RPYTHON: initialization-time only"
+ if hasattr(cls, '__del__') and getattr(cls, "handle_del_manually", False):
+ needsdel = False
assert cls.typedef.acceptable_as_base_class
key = cls, hasdict, wants_slots, needsdel, weakrefable
try:
Modified: pypy/trunk/pypy/module/_stackless/interp_composable_coroutine.py
==============================================================================
--- pypy/trunk/pypy/module/_stackless/interp_composable_coroutine.py (original)
+++ pypy/trunk/pypy/module/_stackless/interp_composable_coroutine.py Thu Apr 16 16:51:37 2009
@@ -31,3 +31,4 @@
getcurrent = interp2app(W_UserCoState.w_getcurrent),
spawn = interp2app(W_UserCoState.w_spawn),
)
+W_UserCoState.acceptable_as_base_class = False
Modified: pypy/trunk/pypy/module/_stackless/test/test_coroutine.py
==============================================================================
--- pypy/trunk/pypy/module/_stackless/test/test_coroutine.py (original)
+++ pypy/trunk/pypy/module/_stackless/test/test_coroutine.py Thu Apr 16 16:51:37 2009
@@ -140,3 +140,25 @@
pass
finally:
stackless.set_stack_depth_limit(st)
+
+class TestRandomThings:
+ def setup_class(cls):
+ cls.space = gettestobjspace(usemodules=('_stackless',))
+
+ def test___del___handling(self):
+ space = self.space
+ w_l = space.newlist([])
+ coro = space.appexec([w_l], """(l):
+ from _stackless import coroutine
+ class MyCoroutine(coroutine):
+ def __del__(self):
+ l.append(self.is_zombie)
+ return MyCoroutine()
+ """)
+ coro.__del__()
+ space.user_del_action.perform(space.getexecutioncontext(), None)
+ coro._kill_finally()
+ assert space.int_w(space.len(w_l)) == 1
+ res = space.is_true(space.getitem(w_l, space.wrap(0)))
+ assert res
+
Modified: pypy/trunk/pypy/rlib/rcoroutine.py
==============================================================================
--- pypy/trunk/pypy/rlib/rcoroutine.py (original)
+++ pypy/trunk/pypy/rlib/rcoroutine.py Thu Apr 16 16:51:37 2009
@@ -292,6 +292,10 @@
if self.frame is not None and syncstate is not None:
syncstate.postpone_deletion(self)
+ # coroutines need complete control over their __del__ behaviour. In
+ # particular they need to care about calling space.userdel themselves
+ handle_del_manually = True
+
def _userdel(self):
# override this for exposed coros
pass
More information about the Pypy-commit
mailing list