mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.14] gh-74389: gh-70560: subprocess.Popen.communicate() now ignores stdin.flush error when closed (GH-142061) (#142064)
gh-74389: gh-70560: subprocess.Popen.communicate() now ignores stdin.flush error when closed (GH-142061)
gh-70560: gh-74389: subprocess.Popen.communicate() now ignores stdin.flush error when closed
with a unittest and news entry.
(cherry picked from commit 923056b2d4)
Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
This commit is contained in:
parent
c7f741100b
commit
6b799e1591
3 changed files with 20 additions and 0 deletions
|
|
@ -1160,6 +1160,19 @@ def test_writes_before_communicate(self):
|
|||
self.assertEqual(stdout, b"bananasplit")
|
||||
self.assertEqual(stderr, b"")
|
||||
|
||||
def test_communicate_stdin_closed_before_call(self):
|
||||
# gh-70560, gh-74389: stdin.close() before communicate()
|
||||
# should not raise ValueError from stdin.flush()
|
||||
with subprocess.Popen([sys.executable, "-c",
|
||||
'import sys; sys.exit(0)'],
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE) as p:
|
||||
p.stdin.close() # Close stdin before communicate
|
||||
# This should not raise ValueError
|
||||
(stdout, stderr) = p.communicate()
|
||||
self.assertEqual(p.returncode, 0)
|
||||
|
||||
def test_universal_newlines_and_text(self):
|
||||
args = [
|
||||
sys.executable, "-c",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue