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

Raise TypeError in ExitStack.enter_context() for bad argument #88637

Closed
serhiy-storchaka opened this issue Jun 21, 2021 · 2 comments
Closed

Raise TypeError in ExitStack.enter_context() for bad argument #88637

serhiy-storchaka opened this issue Jun 21, 2021 · 2 comments
Labels
3.11 stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Jun 21, 2021

BPO 44471
Nosy @ncoghlan, @serhiy-storchaka, @1st1
PRs
  • bpo-44471: Change error type for bad objects in ExitStack.enter_context() #26820
  • Dependencies
  • bpo-12022: AttributeError should report the same details when raised by lookup_special() as when raised in the REPL
  • 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 2021-06-29.08:29:12.209>
    created_at = <Date 2021-06-21.07:43:53.258>
    labels = ['type-feature', 'library', '3.11']
    title = 'Raise TypeError in ExitStack.enter_context() for bad argument'
    updated_at = <Date 2021-06-29.08:29:12.209>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2021-06-29.08:29:12.209>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-06-29.08:29:12.209>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2021-06-21.07:43:53.258>
    creator = 'serhiy.storchaka'
    dependencies = ['12022']
    files = []
    hgrepos = []
    issue_num = 44471
    keywords = ['patch']
    message_count = 2.0
    messages = ['396209', '396708']
    nosy_count = 3.0
    nosy_names = ['ncoghlan', 'serhiy.storchaka', 'yselivanov']
    pr_nums = ['26820']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue44471'
    versions = ['Python 3.11']

    @serhiy-storchaka
    Copy link
    Member Author

    serhiy-storchaka commented Jun 21, 2021

    For consistency with the "with" statement (see bpo-12022) ExitStack.enter_context() should raise TypeError instead of AttributeError if the argument is not a context manager. Same for AsyncExitStack.enter_async_context().

    @serhiy-storchaka serhiy-storchaka added 3.11 stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Jun 21, 2021
    @serhiy-storchaka
    Copy link
    Member Author

    serhiy-storchaka commented Jun 29, 2021

    New changeset 6cb145d by Serhiy Storchaka in branch 'main':
    bpo-44471: Change error type for bad objects in ExitStack.enter_context() (GH-26820)
    6cb145d

    @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.11 stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant