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

os.popen() objects don't support the context manager protocol #51710

Closed
pitrou opened this issue Dec 8, 2009 · 5 comments
Closed

os.popen() objects don't support the context manager protocol #51710

pitrou opened this issue Dec 8, 2009 · 5 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@pitrou
Copy link
Member

pitrou commented Dec 8, 2009

BPO 7461
Nosy @amauryfa, @pitrou
Files
  • with_popen.patch
  • 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 2009-12-09.00:04:04.626>
    created_at = <Date 2009-12-08.19:52:31.387>
    labels = ['type-bug', 'library']
    title = "os.popen() objects don't support the context manager protocol"
    updated_at = <Date 2009-12-09.00:04:04.625>
    user = 'https://github.com/pitrou'

    bugs.python.org fields:

    activity = <Date 2009-12-09.00:04:04.625>
    actor = 'pitrou'
    assignee = 'none'
    closed = True
    closed_date = <Date 2009-12-09.00:04:04.626>
    closer = 'pitrou'
    components = ['Library (Lib)']
    creation = <Date 2009-12-08.19:52:31.387>
    creator = 'pitrou'
    dependencies = []
    files = ['15504']
    hgrepos = []
    issue_num = 7461
    keywords = ['patch']
    message_count = 5.0
    messages = ['96151', '96156', '96158', '96160', '96161']
    nosy_count = 2.0
    nosy_names = ['amaury.forgeotdarc', 'pitrou']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'needs patch'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue7461'
    versions = ['Python 3.1', 'Python 3.2']

    @pitrou
    Copy link
    Member Author

    pitrou commented Dec 8, 2009

    This works under trunk but fails under py3k:

    >>> import os
    >>> with os.popen("ls", "r") as f:
    ...  print(f.read())
    ... 
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AttributeError: __exit__

    @pitrou pitrou added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Dec 8, 2009
    @amauryfa
    Copy link
    Member

    amauryfa commented Dec 8, 2009

    Here is a patch+test

    @pitrou
    Copy link
    Member Author

    pitrou commented Dec 8, 2009

    We should also proxy other special methods. There is __iter__, __next__,
    what else?

    @pitrou
    Copy link
    Member Author

    pitrou commented Dec 8, 2009

    Ah, iterating already works. Sorry for the noise.

    @pitrou
    Copy link
    Member Author

    pitrou commented Dec 9, 2009

    I added a test for iterating and committed the patch in r76723 and
    r76724. Thanks!

    @pitrou pitrou closed this as completed Dec 9, 2009
    @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
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants