-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Intersection of dict view with iterator returns empty set #82391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
In 3.8: >>> {1: 2, 3: 4}.keys() & {1, 2}
{1} In master: >>> {1: 2, 3: 4}.keys() & iter([1, 2])
set() The behavior was changed in bpo-27575. |
Thank you Dong-hee for your fix! |
Please add a test for this regression. |
It was added. Do you mean any special? |
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' |
I think so too. The error actually raises when adding the object into the set. Line 4384 in 818628c
Since the target object to be added is dynamically generated, I think that the issue does not need to be fixed. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: