From 83a8a06331f604c964531d063e0be57f7a459d82 Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith [Google]" Date: Fri, 30 Sep 2022 17:28:45 +0000 Subject: [PATCH 1/2] gh-87597: Document TimeoutExpired.stdout & .stderr types. This documents the behavior that has always been the case since timeout support was introduced in Python 3.3. --- Doc/library/subprocess.rst | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst index 43d6ffceee8fc8..263bff76112624 100644 --- a/Doc/library/subprocess.rst +++ b/Doc/library/subprocess.rst @@ -193,7 +193,10 @@ underlying :class:`Popen` interface can be used directly. .. attribute:: output Output of the child process if it was captured by :func:`run` or - :func:`check_output`. Otherwise, ``None``. + :func:`check_output`. Otherwise, ``None``. This is always + :class:`bytes` when any output was captured regardless of the + ``text=True`` setting. It may be ``None`` when there was no output + captured. .. attribute:: stdout @@ -202,7 +205,9 @@ underlying :class:`Popen` interface can be used directly. .. attribute:: stderr Stderr output of the child process if it was captured by :func:`run`. - Otherwise, ``None``. + Otherwise, ``None``. This is always :class:`bytes` when stderr output + was captured regardless of the ``text=True`` setting. It may be + ``None`` when there was no stderr output captured. .. versionadded:: 3.3 From 35dcb7d893eb4d980ba8744c51ed1126618fdcb3 Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith [Google]" Date: Fri, 30 Sep 2022 17:38:20 +0000 Subject: [PATCH 2/2] slight rewording clarification. That is is None even when people ask to capture output but the process generated no output is a long standing API wart. --- Doc/library/subprocess.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst index 263bff76112624..dee5bd879db5b5 100644 --- a/Doc/library/subprocess.rst +++ b/Doc/library/subprocess.rst @@ -195,8 +195,8 @@ underlying :class:`Popen` interface can be used directly. Output of the child process if it was captured by :func:`run` or :func:`check_output`. Otherwise, ``None``. This is always :class:`bytes` when any output was captured regardless of the - ``text=True`` setting. It may be ``None`` when there was no output - captured. + ``text=True`` setting. It may remain ``None`` instead of ``b''`` + when no output was observed. .. attribute:: stdout @@ -206,8 +206,8 @@ underlying :class:`Popen` interface can be used directly. Stderr output of the child process if it was captured by :func:`run`. Otherwise, ``None``. This is always :class:`bytes` when stderr output - was captured regardless of the ``text=True`` setting. It may be - ``None`` when there was no stderr output captured. + was captured regardless of the ``text=True`` setting. It may remain + ``None`` instead of ``b''`` when no stderr output was observed. .. versionadded:: 3.3