Message4929

Author scoder
Recipients scoder
Date 2009-07-20.11:40:55
SpamBayes Score 0.012547309
Marked as misclassified No
Message-id <1248090055.85.0.458506171667.issue1407@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2009-07-20 11:40:55scodersetrecipients: + scoder
2009-07-20 11:40:55scodersetmessageid: <1248090055.85.0.458506171667.issue1407@psf.upfronthosting.co.za>
2009-07-20 11:40:55scoderlinkissue1407 messages
2009-07-20 11:40:55scodercreate