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.stdin/stdout/stderr documentation should mention object type
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, ethan.furman, ezio.melotti, martin.panter, nikratio, python-dev
Priority: normal Keywords: patch

Created on 2013-04-21 23:14 by nikratio, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
subprocess_rst.diff nikratio, 2013-07-01 00:28
issue17814.patch nikratio, 2014-01-12 02:20
Messages (8)
msg187535 - (view) Author: Nikolaus Rath (nikratio) * Date: 2013-04-21 23:14
The subprocess documentation currently just says that Popen.stdin et all are "file objects", which is linked to the glossary entry. This isn't very helpful, as it doesn't tell whether the streams are bytes or text streams.

Suggested patch:

diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst
--- a/Doc/library/subprocess.rst
+++ b/Doc/library/subprocess.rst
@@ -677,21 +677,29 @@
 
 .. attribute:: Popen.stdin
 
-   If the *stdin* argument was :data:`PIPE`, this attribute is a :term:`file
-   object` that provides input to the child process.  Otherwise, it is ``None``.
+   If the *stdin* argument was :data:`PIPE`, this attribute is a
+   :class:`io.BufferedWriter` (if the *universal_newlines* argument
+   was False) or :class:`io.TextIOWrapper` (if the
+   *universal_newlines* argument was True) object that provides input
+   to the child process. Otherwise, it is ``None``.
 
 
 .. attribute:: Popen.stdout
 
-   If the *stdout* argument was :data:`PIPE`, this attribute is a :term:`file
-   object` that provides output from the child process.  Otherwise, it is ``None``.
+   If the *stdout* argument was :data:`PIPE`, this attribute is a
+   :class:`io.BufferedReader` (if the *universal_newlines* argument
+   was False) or :class:`io.TextIOWrapper` (if the
+   *universal_newlines* argument was True) object that provides output
+   from the child process. Otherwise, it is ``None``.
 
 
 .. attribute:: Popen.stderr
 
-   If the *stderr* argument was :data:`PIPE`, this attribute is a :term:`file
-   object` that provides error output from the child process.  Otherwise, it is
-   ``None``.
+   If the *stderr* argument was :data:`PIPE`, this attribute is a
+   :class:`io.BufferedReader` (if the *universal_newlines* argument
+   was False) or :class:`io.TextIOWrapper` (if the
+   *universal_newlines* argument was True) object that provides output
+   from the child process. Otherwise, it is ``None``.
 
 
 .. attribute:: Popen.pid
msg187536 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2013-04-21 23:19
I think the specific classes are an implementation detail, but mentioning if the file object is a bytes or text stream seems reasonable.
(Also it's better if you attach patches, instead of pasting them in the message.)
msg187538 - (view) Author: Nikolaus Rath (nikratio) * Date: 2013-04-21 23:27
I think it would also be rather important to know if the streams are buffered or not.
msg192098 - (view) Author: Nikolaus Rath (nikratio) * Date: 2013-07-01 00:29
patch attached.
msg207671 - (view) Author: Nikolaus Rath (nikratio) * Date: 2014-01-08 05:47
*ping*

Is this suitable for inclusion? Or do I need to do anything else?
msg207905 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2014-01-11 11:14
The patch specifies the stream types are either BufferedReader/Writer, TextIOWrapper, or None. However they can also be plain FileIO in my experience (Python 3.3 with bufsize=0).

Maybe it would be simpler to defer to the documentation for open(), which already mentions the three possible layers of file wrapping. Although, looking at the code just now, the TextIOWrapper is added separately by the “subprocess” module, and uses write_through=True.
msg207924 - (view) Author: Nikolaus Rath (nikratio) * Date: 2014-01-12 02:20
Thanks for looking at this Martin! I have attached an updated patch that includes a reference to open and slightly changed language.


But please, let's not have the best be the enemy of the good here. There will probably always be room for further improvement, but if the patch as-is improves over the status quo - can't it just be applied? It's not as if this is the last and only chance to make changes...
msg208388 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-01-18 05:49
New changeset 946257d3c648 by Benjamin Peterson in branch '3.3':
describe type of Popen streams (closes #17814)
http://hg.python.org/cpython/rev/946257d3c648

New changeset 1a7d416c57ff by Benjamin Peterson in branch 'default':
merge 3.3 (#17814)
http://hg.python.org/cpython/rev/1a7d416c57ff
History
Date User Action Args
2022-04-11 14:57:44adminsetgithub: 62014
2014-01-18 05:49:38python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg208388

resolution: fixed
stage: needs patch -> resolved
2014-01-18 04:37:32terry.reedysetversions: - Python 3.1, Python 3.2, Python 3.5
2014-01-18 02:48:24ethan.furmansetnosy: + ethan.furman
2014-01-12 02:20:27nikratiosetfiles: + issue17814.patch

messages: + msg207924
versions: + Python 3.1, Python 3.2, Python 3.5
2014-01-11 11:14:14martin.pantersetnosy: + martin.panter
messages: + msg207905
2014-01-08 05:47:22nikratiosetmessages: + msg207671
2013-07-01 00:29:54nikratiosetmessages: + msg192098
2013-07-01 00:28:51nikratiosetfiles: + subprocess_rst.diff
keywords: + patch
2013-04-21 23:27:50nikratiosetmessages: + msg187538
2013-04-21 23:19:34ezio.melottisetversions: + Python 2.7, Python 3.3, Python 3.4
nosy: + ezio.melotti

messages: + msg187536

stage: needs patch
2013-04-21 23:14:46nikratiocreate