Title: ClassCastException when adding list of non-PyObjects
Type: crash Severity: normal
Components: Core Versions: Jython 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: stefan.richthofer Nosy List: jeff.allen, jonathan.simmonds, stefan.richthofer
Priority: normal Keywords:

Created on 2018-05-23.13:16:34 by jonathan.simmonds, last changed 2018-11-25.07:56:29 by jeff.allen.

File name Uploaded Description Edit Remove jonathan.simmonds, 2018-05-23.13:16:34 Bug reproducer
msg12000 (view) Author: Jonathan Simmonds (jonathan.simmonds) Date: 2018-05-23.13:17:23
As of Jython 2.7.1, adding a list containing non-PyObjects to another will result in a "java.lang.ClassCastException: <java type> cannot be cast to org.python.core.PyObject". The attached reproducer illustrates the problem - it works in 2.7.0 but not in 2.7.1+, instead failing on the final line.

This appears to be the result of a simple refactor ( rather than an intentional change: PyList.add takes Objects and performs the java2py wrapping itself, so attempting to cast the list to PyObjects before this point is incorrect.
msg12002 (view) Author: Jeff Allen (jeff.allen) Date: 2018-05-26.09:07:59
Thanks for reporting this, and especially for pinpointing the change. Sometimes one forgets just how elastic Jython is.

In some ways this is an interesting counterpart to "when are two lists equal" #2639, where the twist is objects on the list that are equal in Python but not in Java (e.g. 1==True).
msg12003 (view) Author: Stefan Richthofer (stefan.richthofer) Date: 2018-05-27.14:31:08
Sorry guys for messing this up. I'm currently on vacation and have only mobile device with me. Will fix it as soon as I'm back...
msg12009 (view) Author: Stefan Richthofer (stefan.richthofer) Date: 2018-06-17.11:51:13
Should be fixed as of
Date User Action Args
2018-11-25 07:56:29jeff.allensetstatus: pending -> closed
2018-06-23 18:31:18stefan.richthofersetresolution: accepted -> fixed
2018-06-17 11:51:13stefan.richthofersetstatus: open -> pending
messages: + msg12009
2018-05-27 14:31:08stefan.richthofersetassignee: stefan.richthofer
messages: + msg12003
2018-05-26 09:08:00jeff.allensetpriority: normal
nosy: + stefan.richthofer, jeff.allen
resolution: accepted
messages: + msg12002
2018-05-23 13:17:23jonathan.simmondssetmessages: + msg12000
2018-05-23 13:16:34jonathan.simmondscreate