Message12126
Don't worry: all contributions gratefully received, at whatever pace. The recent changes under #2686 don't fix this, they just removed one confusion factor. (My refactoring was based on main.c in Python 2.7.15, BTW.)
PS jython-jvm9> dist\bin\jython -c "import sys; print 'ps1' in dir(sys)"
True
PS jython-jvm9> python -c "import sys; print 'ps1' in dir(sys)"
False
In #2686 I removed a complicating factor where we were setting ps1 and ps2 in the Jython main to empty strings. (This had been an incorrect fix for a different bug.)
Here's how I see this one. When a module is defined in Java, the attributes Python sees will be the instance or static members that appear in the Java class, both data and methods. There is magic in PyType that fills the module __dict__ with entries obtained by inspection, where the key is the name of the Java attribute, and the value is a wrapper (PyReflectedField) that can get and sometimes set the Java member. Here "set" means write the Java member, not (as might be the case in Python) change the entry in the dictionary, so a reference from Java, that knows nothing about the __dict__, sees the changed value. It is hardly ever necessary to permit deletion, but here it is.
So how to represent that? Setting the value to null is a natural choice, but the normal wrapper maps null to None. So we invented the special value AttributeDeleted.INSTANCE (https://hg.python.org/jython/rev/7c709bc88e7f) and use it here for ps* (https://hg.python.org/jython/rev/23c3effa5d4f), but it means we have to give it special treatment, which we've neglected to do in dir().
A change to __rawdir__ to pretend that we didn't see any attribute with value AttributeDeleted.INSTANCE would fix this issue, I think. This test should have a companion that verifies that for dir(): https://hg.python.org/jython/file/23c3effa5d4f/Lib/test/test_sys_jy.py#l262 |
|
Date |
User |
Action |
Args |
2018-09-28 07:15:15 | jeff.allen | set | messageid: <1538118915.8.0.545547206417.issue2305@psf.upfronthosting.co.za> |
2018-09-28 07:15:15 | jeff.allen | set | recipients:
+ jeff.allen, zyasoft, Arfrever, psykiatris |
2018-09-28 07:15:15 | jeff.allen | link | issue2305 messages |
2018-09-28 07:15:14 | jeff.allen | create | |
|