This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Is contextlib.redirect_stdout reentrant or not?
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.4, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ncoghlan Nosy List: berker.peksag, docs@python, ncoghlan, perey, python-dev, rhettinger
Priority: normal Keywords: patch

Created on 2014-03-25 09:36 by perey, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue21061.diff berker.peksag, 2014-10-11 10:26 review
Messages (5)
msg214801 - (view) Author: Timothy Pederick (perey) Date: 2014-03-25 09:36
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 issue19403, 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...
msg214804 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2014-03-25 10:34
Indeed, it is actually reentrant now - the part that claims it isn't needs to be tweaked appropriately.
msg229074 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2014-10-11 10:26
Here is a simple patch to correct the redirect_stdout documentation.
msg229108 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-10-12 00:25
New changeset dafbd78ac15b by Nick Coghlan in branch '3.4':
Issue #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 #21061 fix from 3.4
https://hg.python.org/cpython/rev/83540d7b7366
msg229110 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2014-10-12 00:27
Thanks folks - the outdated cross reference has been updated as Berker suggested.
History
Date User Action Args
2022-04-11 14:58:00adminsetgithub: 65260
2014-10-12 00:27:41ncoghlansetstatus: open -> closed
type: enhancement
messages: + msg229110

resolution: fixed
stage: patch review -> resolved
2014-10-12 00:25:59python-devsetnosy: + python-dev
messages: + msg229108
2014-10-11 17:20:47rhettingersetassignee: rhettinger -> ncoghlan
2014-10-11 17:11:07rhettingersetassignee: docs@python -> rhettinger

nosy: + rhettinger
2014-10-11 10:26:52berker.peksagsetfiles: + issue21061.diff

nosy: + berker.peksag
messages: + msg229074

keywords: + patch
stage: patch review
2014-03-25 10:34:03ncoghlansetmessages: + msg214804
2014-03-25 10:21:04berker.peksagsetnosy: + ncoghlan
2014-03-25 09:36:05pereycreate