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: Popen() object stdout attribute reassignment behaviour
Type: behavior Stage: needs patch
Components: Documentation Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: georg.brandl, giampaolo.rodola, iritkatriel, maaz92, terry.reedy, vincent.legoll, vlegoll
Priority: normal Keywords:

Created on 2008-08-26 15:57 by vincent.legoll, last changed 2022-04-11 14:56 by admin.

Messages (5)
msg71983 - (view) Author: Vincent Legoll (vincent.legoll) Date: 2008-08-26 15:57
The subprocess.Popen() object documentation should indicate
that the stdout attribute should not be modified after
object construction. Because that won't work.

Or the attribute may be rendered read-only

>>> from subprocess import Popen, PIPE
>>> import sys, os
>>> p1 = Popen(["echo", "1"], stdout = PIPE)
>>> p2 = Popen(["cat"], stdin = p1.stdout, stderr = PIPE, stdout = PIPE)
>>> p2.stdout = sys.stdout
>>> print p2.communicate()

This blocks forever
msg107970 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-06-17 00:34
While it could be argued that it is 'obvious' that changing the stdin, stdout, stderr, and pid of a processes cannot work, I agree that a small addition would be good. In 17.1.2. Popen Objects, after "The following attributes are also available", insert " (do not try to change them)" before ':'.

Actually, it seems to me that the attributes should actually be read-only (in 3.2) if possible (via custom Popen.__setattr__), in which case the only doc change needed (for 3.2) would be insertion of 'read-only' before 'attributes'.

Georg, if you know the id of the subprocess maintainer (if there is one now), could you add him to the nosy list for an opinion or comment?
msg107976 - (view) Author: Legoll Vincent (vlegoll) Date: 2010-06-17 01:10
On Thu, Jun 17, 2010 at 2:34 AM, Terry J. Reedy <report@bugs.python.org> wrote:
> While it could be argued that it is 'obvious'

What is obvious for someone maybe is not for others, if I tried to modify it,
that was on the (false) assumption that it will do what I wanted (whatever
that is)...

Adding more precision to documentation or making the interface fool proof
will make life of dumb devs like me easier by not having to guess or try.

Thanks for taking care of this.
msg281545 - (view) Author: Mohammad Maaz Khan (maaz92) Date: 2016-11-23 08:44
Hi, I want to update the doc for this. This will be my first attempt to update the documentation.
msg407713 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-12-05 15:57
The situation is the same in 3.11, both doc and implementation.
History
Date User Action Args
2022-04-11 14:56:38adminsetgithub: 47937
2021-12-05 15:57:52iritkatrielsetnosy: + iritkatriel

messages: + msg407713
versions: + Python 3.9, Python 3.10, Python 3.11, - Python 2.7, Python 3.5, Python 3.6, Python 3.7
2016-12-06 00:26:48martin.pantersetstage: needs patch
versions: + Python 3.5, Python 3.6, Python 3.7, - Python 2.6, Python 3.1, Python 3.2
2016-11-23 08:44:48maaz92setnosy: + maaz92
messages: + msg281545
2010-10-29 10:07:21adminsetassignee: georg.brandl -> docs@python
2010-06-17 23:59:17giampaolo.rodolasetnosy: + giampaolo.rodola
2010-06-17 01:10:14vlegollsetnosy: + vlegoll
messages: + msg107976
2010-06-17 00:34:45terry.reedysetnosy: + terry.reedy

messages: + msg107970
versions: + Python 2.6, Python 3.1, Python 2.7, Python 3.2, - Python 2.5
2008-08-26 15:57:45vincent.legollcreate