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

contextlib.nullcontext doesn't work with async context managers #85715

Closed
tomgrin10 mannequin opened this issue Aug 13, 2020 · 4 comments
Closed

contextlib.nullcontext doesn't work with async context managers #85715

tomgrin10 mannequin opened this issue Aug 13, 2020 · 4 comments
Labels
3.10 expert-asyncio stdlib type-feature

Comments

@tomgrin10
Copy link
Mannequin

@tomgrin10 tomgrin10 mannequin commented Aug 13, 2020

BPO 41543
Nosy @njsmith, @asvetlov, @1st1, @tomgrin10
PRs
  • #21870
  • 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 2020-11-09.13:24:59.262>
    created_at = <Date 2020-08-13.20:58:48.583>
    labels = ['type-feature', 'library', '3.10', 'expert-asyncio']
    title = "contextlib.nullcontext doesn't work with async context managers"
    updated_at = <Date 2020-11-09.13:24:59.261>
    user = 'https://github.com/tomgrin10'

    bugs.python.org fields:

    activity = <Date 2020-11-09.13:24:59.261>
    actor = 'asvetlov'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-11-09.13:24:59.262>
    closer = 'asvetlov'
    components = ['Library (Lib)', 'asyncio']
    creation = <Date 2020-08-13.20:58:48.583>
    creator = 'tomgrin10'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 41543
    keywords = ['patch']
    message_count = 4.0
    messages = ['375346', '375351', '375357', '380582']
    nosy_count = 4.0
    nosy_names = ['njs', 'asvetlov', 'yselivanov', 'tomgrin10']
    pr_nums = ['21870']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue41543'
    versions = ['Python 3.10']

    @tomgrin10
    Copy link
    Mannequin Author

    @tomgrin10 tomgrin10 mannequin commented Aug 13, 2020

    contextlib.nullcontext cannot be used with async conetext managers, because it implements only __enter__ and __exit__, and doesn't implement __aenter__ and __aexit__.

    @tomgrin10 tomgrin10 mannequin added stdlib expert-asyncio type-feature labels Aug 13, 2020
    @1st1
    Copy link
    Member

    @1st1 1st1 commented Aug 13, 2020

    I typically don't like objects that support both with and async with, but in this case I think that's appropriate. Nathaniel, Andrew, what do you think?

    @njsmith
    Copy link
    Contributor

    @njsmith njsmith commented Aug 13, 2020

    It does seem pretty harmless in this case.

    @asvetlov
    Copy link
    Contributor

    @asvetlov asvetlov commented Nov 9, 2020

    New changeset a117167 by Tom Gringauz in branch 'master':
    bpo-41543: contextlib.nullcontext can fill in for an async context manager (GH-21870)
    a117167

    @asvetlov asvetlov added the 3.10 label Nov 9, 2020
    @asvetlov asvetlov closed this as completed Nov 9, 2020
    @asvetlov asvetlov added the 3.10 label Nov 9, 2020
    @asvetlov asvetlov closed this as completed Nov 9, 2020
    @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.10 expert-asyncio stdlib type-feature
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants