summaryrefslogtreecommitdiffstats
path: root/Lib/subprocess.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r--Lib/subprocess.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 192185d..bdbcc6b 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -697,6 +697,16 @@ class Popen(object):
data = data.replace(b"\r\n", b"\n").replace(b"\r", b"\n")
return data.decode(encoding)
+ def __enter__(self):
+ return self
+
+ def __exit__(self, type, value, traceback):
+ if self.stdout:
+ self.stdout.close()
+ if self.stderr:
+ self.stderr.close()
+ if self.stdin:
+ self.stdin.close()
def __del__(self, _maxsize=sys.maxsize, _active=_active):
if not self._child_created: