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

Is contextlib.redirect_stdout reentrant or not? #65260

Closed
perey mannequin opened this issue Mar 25, 2014 · 5 comments
Closed

Is contextlib.redirect_stdout reentrant or not? #65260

perey mannequin opened this issue Mar 25, 2014 · 5 comments
Assignees
Labels
docs Documentation in the Doc dir type-feature A feature request or enhancement

Comments

@perey
Copy link
Mannequin

perey mannequin commented Mar 25, 2014

BPO 21061
Nosy @rhettinger, @ncoghlan, @berkerpeksag
Files
  • issue21061.diff
  • 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/ncoghlan'
    closed_at = <Date 2014-10-12.00:27:41.378>
    created_at = <Date 2014-03-25.09:36:05.970>
    labels = ['type-feature', 'docs']
    title = 'Is contextlib.redirect_stdout reentrant or not?'
    updated_at = <Date 2014-10-12.00:27:41.377>
    user = 'https://bugs.python.org/perey'

    bugs.python.org fields:

    activity = <Date 2014-10-12.00:27:41.377>
    actor = 'ncoghlan'
    assignee = 'ncoghlan'
    closed = True
    closed_date = <Date 2014-10-12.00:27:41.378>
    closer = 'ncoghlan'
    components = ['Documentation']
    creation = <Date 2014-03-25.09:36:05.970>
    creator = 'perey'
    dependencies = []
    files = ['36877']
    hgrepos = []
    issue_num = 21061
    keywords = ['patch']
    message_count = 5.0
    messages = ['214801', '214804', '229074', '229108', '229110']
    nosy_count = 6.0
    nosy_names = ['rhettinger', 'ncoghlan', 'docs@python', 'perey', 'python-dev', 'berker.peksag']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue21061'
    versions = ['Python 3.4', 'Python 3.5']

    @perey
    Copy link
    Mannequin Author

    perey mannequin commented Mar 25, 2014

    The docs are contradictory on whether or not contextlib.redirect_stdout is reentrant, or reusable-but-not-reentrant. This would seem to be an oversight from bpo-19403, which probably should have changed "reusable but not reentrant" to "reentrant".

    Present in both current and upcoming docs:
    http://docs.python.org/3/library/contextlib.html
    http://docs.python.org/3.5/library/contextlib.html

    contextlib.redirect_stdout(new_target)
      ...
      This context manager is reusable but not reentrant.

    29.6.3.1. Reentrant context managers
    ...
    threading.RLock is an example of a reentrant context manager, as are suppress() and redirect_stdout().
    ...
    Note also that being reentrant is not the same thing as being thread safe. redirect_stdout(), for example...

    @perey perey mannequin assigned docspython Mar 25, 2014
    @perey perey mannequin added the docs Documentation in the Doc dir label Mar 25, 2014
    @ncoghlan
    Copy link
    Contributor

    Indeed, it is actually reentrant now - the part that claims it isn't needs to be tweaked appropriately.

    @berkerpeksag
    Copy link
    Member

    Here is a simple patch to correct the redirect_stdout documentation.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Oct 12, 2014

    New changeset dafbd78ac15b by Nick Coghlan in branch '3.4':
    Issue bpo-21061: correctly note redirect_stdout is reentrant
    https://hg.python.org/cpython/rev/dafbd78ac15b

    New changeset 83540d7b7366 by Nick Coghlan in branch 'default':
    Merge issue bpo-21061 fix from 3.4
    https://hg.python.org/cpython/rev/83540d7b7366

    @ncoghlan
    Copy link
    Contributor

    Thanks folks - the outdated cross reference has been updated as Berker suggested.

    @ncoghlan ncoghlan added the type-feature A feature request or enhancement label Oct 12, 2014
    @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
    docs Documentation in the Doc dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants