Commit c6cb4a41 authored by Jason Madden's avatar Jason Madden

Fix https://bugs.python.org/issue32270 to get Python 3.7.2 test_subprocess working.

parent 9ba08abb
...@@ -25,6 +25,11 @@ ...@@ -25,6 +25,11 @@
- The result of ``gevent.ssl.SSLSocket.makefile()`` can be used as a - The result of ``gevent.ssl.SSLSocket.makefile()`` can be used as a
context manager on Python 2. context manager on Python 2.
- subprocess: No longer close redirected FDs if they are in
``pass_fds``. This is `a bugfix from Python 3.7
<https://bugs.python.org/issue32270>`_ applied to all versions
gevent runs on.
1.4.0 (2019-01-04) 1.4.0 (2019-01-04)
================== ==================
......
...@@ -56,9 +56,9 @@ if 'namedtuple' in __all__: ...@@ -56,9 +56,9 @@ if 'namedtuple' in __all__:
# See notes in _socket2.py. Python 3 returns much nicer # See notes in _socket2.py. Python 3 returns much nicer
# `io` object wrapped around a SocketIO class. # `io` object wrapped around a SocketIO class.
assert not hasattr(__ssl__._fileobject, '__enter__') # pylint:disable=used-before-assignment assert not hasattr(__ssl__._fileobject, '__enter__') # pylint:disable=no-member
class _fileobject(__ssl__._fileobject): # pylint:no-member class _fileobject(__ssl__._fileobject): # pylint:disable=no-member
def __enter__(self): def __enter__(self):
return self return self
......
...@@ -1376,8 +1376,10 @@ class Popen(object): ...@@ -1376,8 +1376,10 @@ class Popen(object):
# is possible that it is overwritten (#12607). # is possible that it is overwritten (#12607).
if c2pwrite == 0: if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite) c2pwrite = os.dup(c2pwrite)
_set_inheritable(c2pwrite, False)
while errwrite in (0, 1): while errwrite in (0, 1):
errwrite = os.dup(errwrite) errwrite = os.dup(errwrite)
_set_inheritable(errwrite, False)
# Dup fds for child # Dup fds for child
def _dup2(existing, desired): def _dup2(existing, desired):
...@@ -1401,12 +1403,19 @@ class Popen(object): ...@@ -1401,12 +1403,19 @@ class Popen(object):
# Close pipe fds. Make sure we don't close the # Close pipe fds. Make sure we don't close the
# same fd more than once, or standard fds. # same fd more than once, or standard fds.
if not PY3:
closed = set([None]) closed = set([None])
for fd in [p2cread, c2pwrite, errwrite]: for fd in [p2cread, c2pwrite, errwrite]:
if fd not in closed and fd > 2: if fd not in closed and fd > 2:
os.close(fd) os.close(fd)
closed.add(fd) closed.add(fd)
# Python 3 (with a working set_inheritable):
# We no longer manually close p2cread,
# c2pwrite, and errwrite here as
# _close_open_fds takes care when it is
# not already non-inheritable.
if cwd is not None: if cwd is not None:
try: try:
os.chdir(cwd) os.chdir(cwd)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment