summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-02-28 10:45:00 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-02-28 10:45:00 (GMT)
commit86ba76570590b10ebd0b6f9b2e53252d8127de0e (patch)
tree721bdd46910e542d97e6ef038b73b08d46ca337f /Lib/test
parent7e8c7956a7edc1505055d3dd9e5180fa30a3cab9 (diff)
parentab900c21fcfb08f13467d1c6f47d03ab90180f89 (diff)
downloadcpython-86ba76570590b10ebd0b6f9b2e53252d8127de0e.zip
cpython-86ba76570590b10ebd0b6f9b2e53252d8127de0e.tar.gz
cpython-86ba76570590b10ebd0b6f9b2e53252d8127de0e.tar.bz2
Issue #21619: Popen objects no longer leave a zombie after exit in the with
statement if the pipe was broken. Patch by Martin Panter.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_subprocess.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 460876f..abce481 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -2502,6 +2502,21 @@ class ContextManagerTests(BaseTestCase):
stderr=subprocess.PIPE) as proc:
pass
+ def test_broken_pipe_cleanup(self):
+ """Broken pipe error should not prevent wait() (Issue 21619)"""
+ proc = subprocess.Popen([sys.executable, "-c",
+ "import sys;"
+ "sys.stdin.close();"
+ "sys.stdout.close();" # Signals that input pipe is closed
+ ], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+ proc.stdout.read() # Make sure subprocess has closed its input
+ proc.stdin.write(b"buffered data")
+ self.assertIsNone(proc.returncode)
+ self.assertRaises(BrokenPipeError, proc.__exit__, None, None, None)
+ self.assertEqual(0, proc.returncode)
+ self.assertTrue(proc.stdin.closed)
+ self.assertTrue(proc.stdout.closed)
+
def test_main():
unit_tests = (ProcessTestCase,