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

Commit 4345a1a

Browse filesBrowse files
committed
Move err_close_fds adds next to pipe creation.
1 parent 99c03e9 commit 4345a1a
Copy full SHA for 4345a1a

File tree

1 file changed

+6
-6
lines changed
Filter options

1 file changed

+6
-6
lines changed

‎Lib/subprocess.py

Copy file name to clipboardExpand all lines: Lib/subprocess.py
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,8 +1347,8 @@ def _get_handles(self, stdin, stdout, stderr):
13471347
if p2cread is None:
13481348
p2cread, _ = _winapi.CreatePipe(None, 0)
13491349
p2cread = Handle(p2cread)
1350-
_winapi.CloseHandle(_)
13511350
err_close_fds.append(p2cread)
1351+
_winapi.CloseHandle(_)
13521352
elif stdin == PIPE:
13531353
p2cread, p2cwrite = _winapi.CreatePipe(None, 0)
13541354
p2cread, p2cwrite = Handle(p2cread), Handle(p2cwrite)
@@ -1367,8 +1367,8 @@ def _get_handles(self, stdin, stdout, stderr):
13671367
if c2pwrite is None:
13681368
_, c2pwrite = _winapi.CreatePipe(None, 0)
13691369
c2pwrite = Handle(c2pwrite)
1370-
_winapi.CloseHandle(_)
13711370
err_close_fds.append(c2pwrite)
1371+
_winapi.CloseHandle(_)
13721372
elif stdout == PIPE:
13731373
c2pread, c2pwrite = _winapi.CreatePipe(None, 0)
13741374
c2pread, c2pwrite = Handle(c2pread), Handle(c2pwrite)
@@ -1387,8 +1387,8 @@ def _get_handles(self, stdin, stdout, stderr):
13871387
if errwrite is None:
13881388
_, errwrite = _winapi.CreatePipe(None, 0)
13891389
errwrite = Handle(errwrite)
1390-
_winapi.CloseHandle(_)
13911390
err_close_fds.append(errwrite)
1391+
_winapi.CloseHandle(_)
13921392
elif stderr == PIPE:
13931393
errread, errwrite = _winapi.CreatePipe(None, 0)
13941394
errread, errwrite = Handle(errread), Handle(errwrite)
@@ -1678,9 +1678,9 @@ def _get_handles(self, stdin, stdout, stderr):
16781678
pass
16791679
elif stdin == PIPE:
16801680
p2cread, p2cwrite = os.pipe()
1681+
err_close_fds.extend((p2cread, p2cwrite))
16811682
if self.pipesize > 0 and hasattr(fcntl, "F_SETPIPE_SZ"):
16821683
fcntl.fcntl(p2cwrite, fcntl.F_SETPIPE_SZ, self.pipesize)
1683-
err_close_fds.extend((p2cread, p2cwrite))
16841684
elif stdin == DEVNULL:
16851685
p2cread = self._get_devnull()
16861686
elif isinstance(stdin, int):
@@ -1693,9 +1693,9 @@ def _get_handles(self, stdin, stdout, stderr):
16931693
pass
16941694
elif stdout == PIPE:
16951695
c2pread, c2pwrite = os.pipe()
1696+
err_close_fds.extend((c2pread, c2pwrite))
16961697
if self.pipesize > 0 and hasattr(fcntl, "F_SETPIPE_SZ"):
16971698
fcntl.fcntl(c2pwrite, fcntl.F_SETPIPE_SZ, self.pipesize)
1698-
err_close_fds.extend((c2pread, c2pwrite))
16991699
elif stdout == DEVNULL:
17001700
c2pwrite = self._get_devnull()
17011701
elif isinstance(stdout, int):
@@ -1708,9 +1708,9 @@ def _get_handles(self, stdin, stdout, stderr):
17081708
pass
17091709
elif stderr == PIPE:
17101710
errread, errwrite = os.pipe()
1711+
err_close_fds.extend((errread, errwrite))
17111712
if self.pipesize > 0 and hasattr(fcntl, "F_SETPIPE_SZ"):
17121713
fcntl.fcntl(errwrite, fcntl.F_SETPIPE_SZ, self.pipesize)
1713-
err_close_fds.extend((errread, errwrite))
17141714
elif stderr == STDOUT:
17151715
if c2pwrite != -1:
17161716
errwrite = c2pwrite

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.