summaryrefslogtreecommitdiff
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, 6 insertions, 4 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 25ffefff6c..6d2c4f5587 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -892,10 +892,12 @@ class Popen(object):
self.stdout.close()
if self.stderr:
self.stderr.close()
- if self.stdin:
- self.stdin.close()
- # Wait for the process to terminate, to avoid zombies.
- self.wait()
+ try: # Flushing a BufferedWriter may raise an error
+ if self.stdin:
+ self.stdin.close()
+ finally:
+ # Wait for the process to terminate, to avoid zombies.
+ self.wait()
def __del__(self, _maxsize=sys.maxsize):
if not self._child_created: