Issue1816134

classification
Title: Issue with Key Comparison in Dicts
Type: Severity: normal
Components: None Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: boisgerault, cgroves
Priority: normal Keywords:

Created on 2007-10-18.21:25:52 by boisgerault, last changed 2007-12-02.19:21:26 by cgroves.

Files
File name Uploaded Description Edit Remove
Wrapper.py boisgerault, 2007-10-18.21:25:52 test file (should not raise KeyError)
test999.py boisgerault, 2007-11-14.09:57:42 test file (consistent with bugtests conventions)
Messages
msg1990 (view) Author: Sébastien Boisgérault (boisgerault) Date: 2007-10-18.21:25:52
The code 'dct[KEY]' may raise a KeyError even if there is in the dict 'dct' a key that has the same hash and compares equal to KEY. 
msg1991 (view) Author: Sébastien Boisgérault (boisgerault) Date: 2007-10-21.13:15:21

The bug is a consequence of the PyString equals implementation:

    public boolean equals(Object other) {
        if (!(other instanceof PyString))
            return false;
        ...
    }
  
If a dictionary that has a string key is queried for a key that does 
not derive from PyString, it cannot find it as PyString.equals will 
always return false, even if both keys may compare equal.
msg1992 (view) Author: Sébastien Boisgérault (boisgerault) Date: 2007-11-14.09:57:43

Remark: the problem is solved if the 'equals' method implemented in PyString is removed.
File Added: test999.py
msg1993 (view) Author: Charlie Groves (cgroves) Date: 2007-12-02.19:21:26
Fix and test case committed in r3753.  Thanks!
History
Date User Action Args
2007-10-18 21:25:52boisgeraultcreate