You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The Mapping ABC's __eq__ method should return NotImplemented if the other type is not a Mapping #52975
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:
assignee=Noneclosed_at=<Date2010-05-21.20:52:37.002>created_at=<Date2010-05-15.22:08:11.016>labels= ['type-bug', 'library']
title="The Mapping ABC's __eq__ method should return NotImplemented if the other type is not a Mapping"updated_at=<Date2010-05-21.20:52:37.001>user='https://bugs.python.org/stutzbach'
The Mapping ABC's __eq__ method should return NotImplemented if the other type is not a Mapping, to give the other type a chance at the comparison. Right now it simply returns false.
The comparison methods on the other ABCs in _abcoll.py already return NotImplemented if they don't recognize the other type.
Yes, I think this is a good candidate for backport. The ABCs are new and their APIs shouldn't contain any obvious bugs such as this.
stutzbach commented on May 19, 2010
stutzbachmannequin
MannequinAuthor
More actions
Here's a patch that adds test cases. It exercises all of the following special methods on Set and Mapping to ensure that they return NotImplemented if they don't recognize the other type.
lt, gt, le, ge, eq, ne, or, and, xor, sub
I made the patch against the py3k branch.
I made the test-case patch separate to make it easier to see the before and after behavior of the actual fix.
Activity
stutzbach commentedon May 15, 2010
The Mapping ABC's __eq__ method should return NotImplemented if the other type is not a Mapping, to give the other type a chance at the comparison. Right now it simply returns false.
The comparison methods on the other ABCs in _abcoll.py already return NotImplemented if they don't recognize the other type.
benjaminp commentedon May 16, 2010
A test would be good.
stutzbach commentedon May 16, 2010
Will do, sometime this week.
rhettinger commentedon May 18, 2010
Backport to 2.6 and 3.1?
pitrou commentedon May 18, 2010
Yes, I think this is a good candidate for backport. The ABCs are new and their APIs shouldn't contain any obvious bugs such as this.
stutzbach commentedon May 19, 2010
Here's a patch that adds test cases. It exercises all of the following special methods on Set and Mapping to ensure that they return NotImplemented if they don't recognize the other type.
I made the patch against the py3k branch.
I made the test-case patch separate to make it easier to see the before and after behavior of the actual fix.
benjaminp commentedon May 19, 2010
Will you post to Rietveld, please?
stutzbach commentedon May 20, 2010
Done: http://codereview.appspot.com/1193044
This is my first time using Rietveld. Let me know if I've done anything wrong.
stutzbach commentedon May 21, 2010
Here is a revised patch based on Benjamin's comments on Rietveld.
benjaminp commentedon May 21, 2010
Fixed in r81414. Thanks for the patch.