Łukasz Langa <[email protected]> added the comment:
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'
----------
nosy: +lukasz.langa
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue38210>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com