[pypy-svn] r67667 - in pypy/branch/spine-of-frames/pypy/module/_stackless: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Mon Sep 14 11:52:59 CEST 2009
Author: cfbolz
Date: Mon Sep 14 11:52:58 2009
New Revision: 67667
Modified:
pypy/branch/spine-of-frames/pypy/module/_stackless/interp_coroutine.py
pypy/branch/spine-of-frames/pypy/module/_stackless/test/test_coroutine.py
Log:
Of course there are features in the stackless module that are completely
untested, which then break translation: Add a test for the ._framestack
attribute on coroutines.
Modified: pypy/branch/spine-of-frames/pypy/module/_stackless/interp_coroutine.py
==============================================================================
--- pypy/branch/spine-of-frames/pypy/module/_stackless/interp_coroutine.py (original)
+++ pypy/branch/spine-of-frames/pypy/module/_stackless/interp_coroutine.py Mon Sep 14 11:52:58 2009
@@ -271,12 +271,15 @@
def w_descr__framestack(space, self):
assert isinstance(self, AppCoroutine)
index = self.subctx.framestackdepth
+ if not index:
+ return space.newtuple([])
items = [None] * index
f = self.subctx.topframe
+ f.force_f_back()
while index > 0:
index -= 1
items[index] = space.wrap(f)
- f = f.f_back
+ f = f.f_back()
assert f is None
return space.newtuple(items)
Modified: pypy/branch/spine-of-frames/pypy/module/_stackless/test/test_coroutine.py
==============================================================================
--- pypy/branch/spine-of-frames/pypy/module/_stackless/test/test_coroutine.py (original)
+++ pypy/branch/spine-of-frames/pypy/module/_stackless/test/test_coroutine.py Mon Sep 14 11:52:58 2009
@@ -116,6 +116,35 @@
co.bind(f)
raises(ValueError, co.bind, f)
+ def test__framestack(self):
+ import _stackless as stackless
+ main = stackless.coroutine.getmain()
+ co = stackless.coroutine()
+ def g():
+ return co._framestack
+ def f():
+ return g()
+
+ co.bind(f)
+ stack = co.switch()
+ assert stack == () # running corountine, _framestack is empty
+
+ co = stackless.coroutine()
+ def g():
+ return main.switch()
+ def f():
+ return g()
+
+ co.bind(f)
+ co.switch()
+ stack = co._framestack
+ assert len(stack) == 2
+ assert stack[0].f_code is f.func_code
+ assert stack[1].f_code is g.func_code
+
+ co = stackless.coroutine()
+
+
class AppTestDirect:
def setup_class(cls):
More information about the Pypy-commit
mailing list