Author: Carl Friedrich Bolz <[email protected]>
Branch: unpickle-coroutine-trampoline
Changeset: r44148:bec188765c99
Date: 2011-05-13 18:46 +0200
http://bitbucket.org/pypy/pypy/changeset/bec188765c99/
Log: (arigo, cfbolz): more unimplemented case
diff --git a/pypy/module/_stackless/interp_coroutine.py
b/pypy/module/_stackless/interp_coroutine.py
--- a/pypy/module/_stackless/interp_coroutine.py
+++ b/pypy/module/_stackless/interp_coroutine.py
@@ -385,14 +385,12 @@
oparg = ord(code[instr]) | ord(code[instr + 1]) << 8
nargs = oparg & 0xff
nkwds = (oparg >> 8) & 0xff
- if space.config.objspace.opcodes.CALL_METHOD and opcode ==
map['CALL_METHOD']:
- if nkwds == 0: # only positional arguments
+ if nkwds == 0: # only positional arguments
+ # fast paths leaves things on the stack, pop them
+ if space.config.objspace.opcodes.CALL_METHOD and opcode ==
map['CALL_METHOD']:
frame.dropvalues(nargs + 2)
- elif opcode == map['CALL_FUNCTION']:
- if nkwds == 0: # only positional arguments
+ elif opcode == map['CALL_FUNCTION']:
frame.dropvalues(nargs + 1)
- else:
- assert 0
# small hack: unlink frame out of the execution context, because
# execute_frame will add it there again
diff --git a/pypy/module/_stackless/test/test_pickle.py
b/pypy/module/_stackless/test/test_pickle.py
--- a/pypy/module/_stackless/test/test_pickle.py
+++ b/pypy/module/_stackless/test/test_pickle.py
@@ -156,6 +156,41 @@
finally:
del sys.modules['mod']
+ def test_starstarargs(self):
+
+ import new, sys
+
+ mod = new.module('mod')
+ sys.modules['mod'] = mod
+ try:
+ exec '''
+output = []
+import _stackless
+def f(coro, n, x, step=4):
+ if n == 0:
+ coro.switch()
+ return
+ f(coro, n-1, 2*x, **{'step': 1})
+ output.append(x)
+
+def example():
+ main_coro = _stackless.coroutine.getcurrent()
+ sub_coro = _stackless.coroutine()
+ sub_coro.bind(f, main_coro, 5, 1, 1)
+ sub_coro.switch()
+
+ import pickle
+ pckl = pickle.dumps(sub_coro)
+ new_coro = pickle.loads(pckl)
+
+ new_coro.switch()
+
+example()
+assert output == [16, 8, 4, 2, 1]
+''' in mod.__dict__
+ finally:
+ del sys.modules['mod']
+
def test_closure(self):
import new, sys
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit