[issue21061] Is contextlib.redirect_stdout reentrant or not?
New submission from Timothy Pederick: 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... ---------- assignee: docs@python components: Documentation messages: 214801 nosy: docs@python, perey priority: normal severity: normal status: open title: Is contextlib.redirect_stdout reentrant or not? versions: Python 3.4, Python 3.5 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue21061> _______________________________________
Changes by Berker Peksag <berker.peksag@gmail.com>: ---------- nosy: +ncoghlan _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue21061> _______________________________________
Nick Coghlan added the comment: Indeed, it is actually reentrant now - the part that claims it isn't needs to be tweaked appropriately. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue21061> _______________________________________
Berker Peksag added the comment: Here is a simple patch to correct the redirect_stdout documentation. ---------- keywords: +patch nosy: +berker.peksag stage: -> patch review Added file: http://bugs.python.org/file36877/issue21061.diff _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue21061> _______________________________________
Changes by Raymond Hettinger <raymond.hettinger@gmail.com>: ---------- assignee: docs@python -> rhettinger nosy: +rhettinger _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue21061> _______________________________________
Changes by Raymond Hettinger <raymond.hettinger@gmail.com>: ---------- assignee: rhettinger -> ncoghlan _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue21061> _______________________________________
Roundup Robot added the comment: 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 ---------- nosy: +python-dev _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue21061> _______________________________________
Nick Coghlan added the comment: Thanks folks - the outdated cross reference has been updated as Berker suggested. ---------- resolution: -> fixed stage: patch review -> resolved status: open -> closed type: -> enhancement _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue21061> _______________________________________
participants (5)
-
Berker Peksag -
Nick Coghlan -
Raymond Hettinger -
Roundup Robot -
Timothy Pederick