Skip to content

The Mapping ABC's __eq__ method should return NotImplemented if the other type is not a Mapping #52975

Closed

Description

@stutzbach
mannequin
BPO 8729
Nosy @rhettinger, @pitrou, @benjaminp
Files
  • mapping.patch: Change Mapping.eq to return NotImplemented if the other type isn't a Mapping
  • eq-test.patch: Add test cases
  • mapping2.patch: Revised patch, with fix and unit tests
  • 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 = None
    closed_at = <Date 2010-05-21.20:52:37.002>
    created_at = <Date 2010-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 = <Date 2010-05-21.20:52:37.001>
    user = 'https://bugs.python.org/stutzbach'

    bugs.python.org fields:

    activity = <Date 2010-05-21.20:52:37.001>
    actor = 'benjamin.peterson'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-05-21.20:52:37.002>
    closer = 'benjamin.peterson'
    components = ['Library (Lib)']
    creation = <Date 2010-05-15.22:08:11.016>
    creator = 'stutzbach'
    dependencies = []
    files = ['17355', '17392', '17433']
    hgrepos = []
    issue_num = 8729
    keywords = ['patch']
    message_count = 10.0
    messages = ['105833', '105846', '105849', '106000', '106001', '106017', '106107', '106131', '106257', '106264']
    nosy_count = 4.0
    nosy_names = ['rhettinger', 'pitrou', 'benjamin.peterson', 'stutzbach']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'patch review'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue8729'
    versions = ['Python 2.6', 'Python 3.1', 'Python 2.7', 'Python 3.2']

    Activity

    1. stutzbach commented on May 15, 2010

      stutzbachmannequin
      MannequinAuthor

      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.

    2. added
      stdlib
      type-bug
      on May 15, 2010
    3. benjaminp commented on May 16, 2010

      @benjaminp
      Contributor

      A test would be good.

    4. stutzbach commented on May 16, 2010

      stutzbachmannequin
      MannequinAuthor

      Will do, sometime this week.

    5. rhettinger commented on May 18, 2010

      @rhettinger
      Contributor

      Backport to 2.6 and 3.1?

    6. pitrou commented on May 18, 2010

      @pitrou
      Member

      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.

    7. stutzbach commented on May 19, 2010

      stutzbachmannequin
      MannequinAuthor

      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.

    8. benjaminp commented on May 19, 2010

      @benjaminp
      Contributor

      Will you post to Rietveld, please?

    9. stutzbach commented on May 20, 2010

      stutzbachmannequin
      MannequinAuthor

      Done: http://codereview.appspot.com/1193044

      This is my first time using Rietveld. Let me know if I've done anything wrong.

    10. stutzbach commented on May 21, 2010

      stutzbachmannequin
      MannequinAuthor

      Here is a revised patch based on Benjamin's comments on Rietveld.

    11. benjaminp commented on May 21, 2010

      @benjaminp
      Contributor

      Fixed in r81414. Thanks for the patch.

    12. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      stdlibtype-bug

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions