This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author lukasz.langa
Recipients corona10, lukasz.langa, rhettinger, serhiy.storchaka, vstinner
Date 2021-07-14.16:24:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1626279853.01.0.203813231131.issue38210@roundup.psfhosted.org>
In-reply-to
Content
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'
History
Date User Action Args
2021-07-14 16:24:13lukasz.langasetrecipients: + lukasz.langa, rhettinger, vstinner, serhiy.storchaka, corona10
2021-07-14 16:24:13lukasz.langasetmessageid: <1626279853.01.0.203813231131.issue38210@roundup.psfhosted.org>
2021-07-14 16:24:12lukasz.langalinkissue38210 messages
2021-07-14 16:24:12lukasz.langacreate