Message397494
This caused an unintentional behavior change in the following code:
>>> {1: 2}.items() & {1: {2: 3}}.items()
set()
Before this change, Python 3.6 - 3.8 behaved like this instead:
>>> {1: 2}.items() & {1: {2: 3}}.items()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'dict'
Interestingly, this doesn't seem to have a negative effect on correctness as the silently omitted unhashable (k, v) pair is only omitted if it's different between the two dictionaries:
>>> {1: {2: 4}}.items() & {1: {2: 3}}.items()
set()
>>> {2: 1, 1: {2: 4}}.items() & {2: 1, 1: {2: 3}}.items()
{(2, 1)}
If it's the same, we still get an error in Python 3.9:
>>> {1: {2: 3}}.items() & {1: {2: 3}}.items()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'dict'
>>> {2: 1, 1: {2: 3}}.items() & {2: 1, 1: {2: 3}}.items()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'dict' |
|
Date |
User |
Action |
Args |
2021-07-14 16:24:13 | lukasz.langa | set | recipients:
+ lukasz.langa, rhettinger, vstinner, serhiy.storchaka, corona10 |
2021-07-14 16:24:13 | lukasz.langa | set | messageid: <1626279853.01.0.203813231131.issue38210@roundup.psfhosted.org> |
2021-07-14 16:24:12 | lukasz.langa | link | issue38210 messages |
2021-07-14 16:24:12 | lukasz.langa | create | |
|