summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorBrian Curtin <brian.curtin@gmail.com>2010-12-03 02:46:02 (GMT)
committerBrian Curtin <brian.curtin@gmail.com>2010-12-03 02:46:02 (GMT)
commit79cdb661f5a6cf8bba07aa50f4451f6c409bb067 (patch)
tree951cc547f5023ab2965b790fe01617e19952d3cf /Doc/library
parent2d93e6ee637f3ec62114919835a32ed009b99a0b (diff)
downloadcpython-79cdb661f5a6cf8bba07aa50f4451f6c409bb067.zip
cpython-79cdb661f5a6cf8bba07aa50f4451f6c409bb067.tar.gz
cpython-79cdb661f5a6cf8bba07aa50f4451f6c409bb067.tar.bz2
Fix #10554. Added context manager support to Popen objects.
Added a few common Popen uses to the tests like we've done for a few other instances of adding context managers. Eventually the entire test suite could be converted to use the context manager format.
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/subprocess.rst10
1 files changed, 10 insertions, 0 deletions
diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst
index 8f9b9ea..e0bb163 100644
--- a/Doc/library/subprocess.rst
+++ b/Doc/library/subprocess.rst
@@ -208,6 +208,16 @@ This module defines one class called :class:`Popen`:
underlying CreateProcess() function. They can specify things such as appearance
of the main window and priority for the new process. (Windows only)
+ Popen objects are supported as context managers via the :keyword:`with` statement,
+ closing any open file descriptors on exit.
+ ::
+
+ with Popen(["ifconfig"], stdout=PIPE) as proc:
+ log.write(proc.stdout.read())
+
+ .. versionchanged:: 3.2
+ Added context manager support.
+
.. data:: PIPE