From: Stefan B. <re...@bu...> - 2009-07-20 11:40:57
|
New submission from Stefan Behnel <sc...@us...>: The following code leads to a ClassCastException: ---------------------------- def add(target): while True: target.send( (yield) + 1 ) def sink(): while True: print( (yield) ) p = add(sink()) ; p.next() p.send(5) # <== fails! p.close() ---------------------------- When running it, I get: Traceback (most recent call last): File "pype/jytest.py", line 15, in <module> p.send(5) File "pype/jytest.py", line 4, in add target.send( (yield) + 1 ) java.lang.ClassCastException: org.python.core.PyGenerator$send_exposer cannot be cast to org.python.core.ThreadState at org.python.pycode._pyx0.add$1(pype/jytest.py:3) at org.python.pycode._pyx0.call_function(pype/jytest.py) at org.python.core.PyTableCode.call(PyTableCode.java:165) at org.python.core.PyGenerator.__iternext__(PyGenerator.java:129) at org.python.core.PyGenerator.__iternext__(PyGenerator.java:112) at org.python.core.PyIterator.next(PyIterator.java:42) at org.python.core.PyGenerator.next(PyGenerator.java:68) at org.python.core.PyGenerator.send(PyGenerator.java:39) at org.python.core.PyGenerator$send_exposer.__call__(Unknown Source) at org.python.core.PyObject.__call__(PyObject.java:401) at org.python.pycode._pyx0.f$0(pype/jytest.py:16) at org.python.pycode._pyx0.call_function(pype/jytest.py) at org.python.core.PyTableCode.call(PyTableCode.java:165) at org.python.core.PyCode.call(PyCode.java:18) at org.python.core.Py.runCode(Py.java:1198) at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:166) at org.python.util.jython.run(jython.java:229) at org.python.util.jython.main(jython.java:117) java.lang.ClassCastException: java.lang.ClassCastException: org.python.core.PyGenerator$send_exposer cannot be cast to org.python.core.ThreadState ---------- components: Core messages: 4929 nosy: scoder severity: normal status: open title: ClassCastException in plain Python coroutine type: behaviour versions: 2.5.0 _______________________________________ Jython tracker <re...@bu...> <http://bugs.jython.org/issue1407> _______________________________________ |