Title: Jython converts None to null when calling put(), but not when setting item with Python syntax
Type: behaviour Severity: major
Components: Core Versions: Jython 2.7.1
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: doublep, zyasoft
Priority: Keywords:

Created on 2019-11-29.15:58:50 by doublep, last changed 2019-12-02.11:09:40 by doublep.

msg12812 (view) Author: (doublep) Date: 2019-11-29.15:58:50
I'm not 100% sure it is a bug, but:

m = HashMap()
m.put (1, None) # => {1=null}

m = HashMap()
m[1] = None # => {1=None}

The latter of course causes exceptions when Java code bumps into a Jython object where it doesn't expect it.

Or is it intended that None is converted to null only when invoking a Java method?
msg12814 (view) Author: Jim Baker (zyasoft) Date: 2019-11-30.00:53:35
This violates our existing semantic equivalence, where we try to translate Python objects to equivalent Java objects in crossing these boundaries. Should be a straightforward fix.
msg12816 (view) Author: (doublep) Date: 2019-12-02.11:04:04
Then I would appreciate a quick fix.

I made a few more tests with HashMap (m) and ArrayList (l):

None translated to null: m.put, a.add, a[...] =, a[...:...] =, a.add

None _preserved as-is_, i.e. a bug: m[...] =, m.setdefault, l.append, l.extend.
msg12818 (view) Author: (doublep) Date: 2019-12-02.11:09:40
By the way, this is a regression compared with 2.5.1 in those cases where methods were available.  E.g.

m = HashMap()
m[1] = None

gives {1=null} on 2.5.1.
Date User Action Args
2019-12-02 11:09:40doublepsetmessages: + msg12818
2019-12-02 11:04:04doublepsetmessages: + msg12816
severity: normal -> major
2019-11-30 00:53:35zyasoftsetmessages: + msg12814
2019-11-29 22:33:53zyasoftsetnosy: + zyasoft
2019-11-29 15:58:50doublepcreate