Message12043

Author jaraco
Recipients jaraco
Date 2018-07-06.03:02:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1530846161.15.0.56676864532.issue2696@psf.upfronthosting.co.za>
In-reply-to
Content
On CPython, invoking open(None) results in a Python Exception (TypeError). On jython, it crashes with a Java exception:

>>> open(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
java.lang.ClassCastException: org.python.core.PyNone cannot be cast to org.python.core.PyString
        at org.python.core.PyFile.file___init__(PyFile.java:173)
        at org.python.core.PyFile$exposed___new__.createOfType(Unknown Source)
        at org.python.core.PyOverridableNew.new_impl(PyOverridableNew.java:12)
        at org.python.core.PyType.invokeNew(PyType.java:583)
        at org.python.core.PyType.type___call__(PyType.java:1815)
        at org.python.core.PyType.__call__(PyType.java:1805)
        at org.python.core.OpenFunction.__call__(__builtin__.java:1725)
        at org.python.core.PyObject.__call__(PyObject.java:480)
        at org.python.core.PyObject.__call__(PyObject.java:484)
        at org.python.pycode._pyx4.f$0(<stdin>:1)
        at org.python.pycode._pyx4.call_function(<stdin>)
        at org.python.core.PyTableCode.call(PyTableCode.java:171)
        at org.python.core.PyCode.call(PyCode.java:18)
        at org.python.core.Py.runCode(Py.java:1614)
        at org.python.core.Py.exec(Py.java:1658)
        at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:276)
        at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java:131)
        at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:116)
        at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:62)
        at org.python.util.InteractiveConsole.push(InteractiveConsole.java:187)
        at org.python.util.InteractiveConsole._interact(InteractiveConsole.java:168)
        at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:126)
        at org.python.util.jython.run(jython.java:419)
        at org.python.util.jython.main(jython.java:142)
java.lang.ClassCastException: java.lang.ClassCastException: org.python.core.PyNone cannot be cast to org.python.core.PyString


As a result, [code like this](https://github.com/jaraco/rwt/blob/0ef1080da43827787846f32c698fe7286d6a7613/rwt/scripts.py#L50-L54) fails to catch the exception.

Perhaps that's by design and the offending code should simply catch BaseException instead. Probably better would be for Jython to raise the same TypeError.
History
Date User Action Args
2018-07-06 03:02:41jaracosetrecipients: + jaraco
2018-07-06 03:02:41jaracosetmessageid: <1530846161.15.0.56676864532.issue2696@psf.upfronthosting.co.za>
2018-07-06 03:02:40jaracolinkissue2696 messages
2018-07-06 03:02:39jaracocreate