Message12129
On second thoughts ... my understanding of the interaction with __dict__ was incorrect.
I should have added that __delattr__ is the implementation of "del" at the REPL. But I was wrong in that we *do* delete ps* from __dict__, as well as set the field member to PyAttributeDeleted.INSTANCE during a call. However, we start in an inconsistent state with ps1, ps2 in the __dict__ but set to PyAttributeDeleted.
In a regular interactive REPL, observe this:
>>> import sys
>>> 'ps2' in dir(sys)
True
>>> del sys.ps2
>>> 'ps2' in dir(sys)
False
>>> sys.ps2 = '::: '
>>> 'ps2' in dir(sys)
False # This is wrong.
I've set breakpoints in PySystemState.__setattr__ and __delattr__, so I can observe how it goes internally. You see that after mid-sequence above, ps2==PyAttributeDeleted and is absent from the dictionary (as reported by dir()). However, putting a value back in ps2 doesn't put it back in __dict__, which is wrong.
We should either 1. always remove/add to __dict__ on del/set, and always use del/set at the Java level or 2. del/set only the Java member (not __dict__) and then respect PyAttributeDeleted everywhere they crop up. It seems like the idea of PyAttributeDeleted is to do the latter, but __setattr__ is incorrect, and __rawdir__. |
|
Date |
User |
Action |
Args |
2018-09-30 15:43:49 | jeff.allen | set | messageid: <1538322229.54.0.545547206417.issue2305@psf.upfronthosting.co.za> |
2018-09-30 15:43:49 | jeff.allen | set | recipients:
+ jeff.allen, zyasoft, Arfrever, psykiatris |
2018-09-30 15:43:49 | jeff.allen | link | issue2305 messages |
2018-09-30 15:43:49 | jeff.allen | create | |
|