Skip to content

AbstractContextManager should support __method__ = None #74452

Closed

Description

@JelleZijlstra
BPO 30266
Nosy @gvanrossum, @ncoghlan, @1st1, @ilevkivskyi, @JelleZijlstra, @Mariatta
PRs
  • bpo-30266: support "= None" pattern in AbstractContextManager #1448
  • [3.6] bpo-30266: support "= None" pattern in AbstractContextManager (… #2054
  • 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 = 'https://github.com/Mariatta'
    closed_at = <Date 2017-06-10.03:38:08.981>
    created_at = <Date 2017-05-04.03:37:32.485>
    labels = ['3.7', 'library']
    title = 'AbstractContextManager should support __method__ = None'
    updated_at = <Date 2017-06-10.04:37:55.104>
    user = 'https://github.com/JelleZijlstra'

    bugs.python.org fields:

    activity = <Date 2017-06-10.04:37:55.104>
    actor = 'JelleZijlstra'
    assignee = 'Mariatta'
    closed = True
    closed_date = <Date 2017-06-10.03:38:08.981>
    closer = 'Mariatta'
    components = ['Library (Lib)']
    creation = <Date 2017-05-04.03:37:32.485>
    creator = 'JelleZijlstra'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 30266
    keywords = []
    message_count = 7.0
    messages = ['292955', '295541', '295547', '295603', '295604', '295607', '295608']
    nosy_count = 6.0
    nosy_names = ['gvanrossum', 'ncoghlan', 'yselivanov', 'levkivskyi', 'JelleZijlstra', 'Mariatta']
    pr_nums = ['1448', '2054']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue30266'
    versions = ['Python 3.6', 'Python 3.7']

    Activity

    1. JelleZijlstra commented on May 4, 2017

      @JelleZijlstra
      MemberAuthor

      Like other ABCs, contextlib.AbstractContextManager should support the pattern where setting a method to None disables structural subtyping, which was introduced across the standard library in bpo-25958. Ivan Levkivskyi suggested making AbstractContextManager support this pattern in CR comments in https://github.com/python/cpython/pull/1412/files#r114482765.

      Should this change be applied to 3.6 as well as master? I'm leaning towards yes, because the resolution to bpo-25958 (https://hg.python.org/cpython/rev/72b9f195569c) added a general statement in the documentation that "Setting a special method to None indicates that the corresponding operation is not available". Thus, the fact that contextlib.AbstractContextManager doesn't obey this rule is a bug.

      I'll send a PR shortly.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      on May 4, 2017
    3. gvanrossum commented on Jun 9, 2017

      @gvanrossum
      Member

      New changeset 57161aa by Guido van Rossum (Jelle Zijlstra) in branch 'master':
      bpo-30266: support "= None" pattern in AbstractContextManager (bpo-1448)
      57161aa

    4. gvanrossum commented on Jun 9, 2017

      @gvanrossum
      Member

      This should be backported to 3.6.

    5. self-assigned this
      on Jun 9, 2017
    6. Mariatta commented on Jun 10, 2017

      @Mariatta
      Member

      New changeset 753422f by Mariatta in branch '3.6':
      bpo-30266: support "= None" pattern in AbstractContextManager (GH-1448) (GH-2054)
      753422f

    7. Mariatta commented on Jun 10, 2017

      @Mariatta
      Member

      PR has been backported to 3.6.

      Thanks :)

    8. gvanrossum commented on Jun 10, 2017

      @gvanrossum
      Member

      Thanks Mariatta!

    9. JelleZijlstra commented on Jun 10, 2017

      @JelleZijlstra
      MemberAuthor

      Thanks for doing the merge and backport!

    10. 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

    Labels

    3.7 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directory

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions