Skip to content
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

AbstractContextManager should support __method__ = None #74452

Closed
JelleZijlstra opened this issue May 4, 2017 · 7 comments
Closed

AbstractContextManager should support __method__ = None #74452

JelleZijlstra opened this issue May 4, 2017 · 7 comments
Assignees
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir

Comments

@JelleZijlstra
Copy link
Member

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']

    @JelleZijlstra
    Copy link
    Member Author

    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.

    @JelleZijlstra JelleZijlstra added 3.7 (EOL) end of life stdlib Python modules in the Lib dir labels May 4, 2017
    @gvanrossum
    Copy link
    Member

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

    @gvanrossum
    Copy link
    Member

    This should be backported to 3.6.

    @Mariatta Mariatta self-assigned this Jun 9, 2017
    @Mariatta
    Copy link
    Member

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

    @Mariatta
    Copy link
    Member

    PR has been backported to 3.6.

    Thanks :)

    @gvanrossum
    Copy link
    Member

    Thanks Mariatta!

    @JelleZijlstra
    Copy link
    Member Author

    Thanks for doing the merge and backport!

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants