Issue2367
 
            
            
            
Created on 2015-06-10.19:33:20 by clevy, last changed 2018-03-22.07:50:53 by jeff.allen. 
 |
 
   | msg10106 (view) | Author: Caleb Levy (clevy) | Date: 2015-06-10.19:33:18 |  |  
   | Take two subclasses of dict which define __hash__ and __eq__ (for example, we want to create an ImmutableMap) so that their hashes are equal, and dict.__eq__(dict1, dict2) returns True, but the objects are NOT equal due to their custom __eq__.
When using them BOTH as dictionary keys, Jython ignores the custom __eq__ upon hash collision and simply overwrites one key with the other. Note from the included tests that a hash collision is NOT the cause; if dict.__eq__(d1, d2) is False, both will still be used as keys.
This problem does not show up when inserting from list, tuple, object or any other classes I have tried.
Of the included unit tests, "test_distinct_in_set" and "test_distinct_as_keys" fail in Jython alone; the rest pass in Jython, CPython 2 and 3, and PyPy 2 and 3. |  
   | msg10107 (view) | Author: Caleb Levy (clevy) | Date: 2015-06-10.19:38:23 |  |  
   | Not sure how to edit a submission, as I have not used this tracker before. Anyway, it should say "inheriting" instead of inserting in the third paragraph. |  
   | msg10124 (view) | Author: Santoso Wijaya (santa4nt) | Date: 2015-06-18.23:13:04 |  |  
   | Additionally:
a = Dict1
b = Dict2
>>> a.__eq__(b)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unbound method __eq__() must be called with Dict1 instance as first argument (got type instance instead) |  
   | msg10125 (view) | Author: Santoso Wijaya (santa4nt) | Date: 2015-06-19.02:59:31 |  |  
   | First draft of a patch that addressed this. I tested this with a version of the sample jythonbug.py, but not yet regressed.
Thoughts? |  
   | msg10743 (view) | Author: Jim Baker (zyasoft) | Date: 2016-02-15.18:54:10 |  |  
   | This bug and possible resolution didn't get the triage it needed in 2.7.1. Defer to 2.7.2 for a fresh look. |  
   | msg11842 (view) | Author: Jeff Allen (jeff.allen) | Date: 2018-03-22.07:50:31 |  |  
   | ... and not for 2.7.2 either. |  |
 
| Date | User | Action | Args |  | 2018-03-22 07:50:53 | jeff.allen | set | priority: normal |  | 2018-03-22 07:50:31 | jeff.allen | set | nosy:
  + jeff.allen messages:
  + msg11842
 milestone: Jython 2.7.2 ->
 |  | 2016-02-15 18:54:11 | zyasoft | set | messages:
  + msg10743 milestone: Jython 2.7.2
 |  | 2015-06-19 18:58:30 | santa4nt | set | files:
  + issue2367.patch |  | 2015-06-19 18:58:17 | santa4nt | set | files:
  - issue2367.patch |  | 2015-06-19 02:59:33 | santa4nt | set | files:
  + issue2367.patch keywords:
  + patch
 messages:
  + msg10125
 |  | 2015-06-18 23:13:05 | santa4nt | set | nosy:
  + santa4nt messages:
  + msg10124
 |  | 2015-06-10 21:36:16 | zyasoft | set | nosy:
  + zyasoft |  | 2015-06-10 19:38:24 | clevy | set | messages:
  + msg10107 |  | 2015-06-10 19:33:20 | clevy | create |  | 
 |