Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion 8 Lib/subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,10 @@ def __init__(self, args, bufsize=-1, executable=None,
to_close.append(self._devnull)
for fd in to_close:
try:
os.close(fd)
if _mswindows and isinstance(fd, Handle):
fd.Close()
else:
os.close(fd)
except OSError:
pass

Expand Down Expand Up @@ -1005,6 +1008,9 @@ def _execute_child(self, args, executable, preexec_fn, close_fds,
errwrite.Close()
if hasattr(self, '_devnull'):
os.close(self._devnull)
# Prevent a double close of these handles/fds from __init__
# on error.
self._closed_child_pipe_fds = True

# Retain the process handle, but close the thread handle
self._child_created = True
Expand Down
9 changes: 5 additions & 4 deletions 9 Lib/test/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -1068,10 +1068,11 @@ def _test_bufsize_equal_one(self, line, expected, universal_newlines):
p.stdin.write(line) # expect that it flushes the line in text mode
os.close(p.stdin.fileno()) # close it without flushing the buffer
read_line = p.stdout.readline()
try:
p.stdin.close()
except OSError:
pass
with support.SuppressCrashReport():
try:
p.stdin.close()
except OSError:
pass
p.stdin = None
self.assertEqual(p.returncode, 0)
self.assertEqual(read_line, expected)
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.