Skip to content

Commit e7b1566

Browse files
committed
Merge branch 'dev' into 3.8
2 parents 6646d4d + deded81 commit e7b1566

File tree

5 files changed

+10
-65
lines changed

5 files changed

+10
-65
lines changed

README.rst

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ The following standard library modules are available on macOS, but not the other
2424
Apple platforms:
2525
* curses
2626
* posixshmem
27-
* posixsubprocess
2827

2928
The binaries support x86_64 and arm64 for macOS; arm64 for iOS and appleTV
3029
devices; and arm64_32 for watchOS. It also supports device simulators on both

patch/Python/Python.patch

+7-61
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ index 509f99ae8e..2005b88e94 100644
707707
+ _CASE_INSENSITIVE_PLATFORMS_STR_KEY)
708708

709709
diff --git a/Lib/os.py b/Lib/os.py
710-
index 253cad1a59..b69d814e7a 100644
710+
index 253cad1a59..b2a6fbfb08 100644
711711
--- a/Lib/os.py
712712
+++ b/Lib/os.py
713713
@@ -34,7 +34,7 @@
@@ -724,7 +724,7 @@ index 253cad1a59..b69d814e7a 100644
724724
del _fscodec
725725

726726
+
727-
+if sys.platform in ('iOS', 'tvos', 'watchos'):
727+
+if sys.platform in ('ios', 'tvos', 'watchos'):
728728
+ allows_subprocesses = False
729729
+else:
730730
+ allows_subprocesses = True
@@ -11454,74 +11454,20 @@ index 9fa21cca38..e346fb4390 100644
1145411454
return f'{userbase}/lib/python{version[0]}.{version[1]}/site-packages'
1145511455

1145611456
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
11457-
index d4d04a5c34..b742063be5 100644
11457+
index d4d04a5c34..0e76349e81 100644
1145811458
--- a/Lib/subprocess.py
1145911459
+++ b/Lib/subprocess.py
11460-
@@ -66,9 +66,13 @@
11461-
_mswindows = True
11462-
except ModuleNotFoundError:
11463-
_mswindows = False
11464-
- import _posixsubprocess
11465-
- import select
11466-
- import selectors
11467-
+ try:
11468-
+ import _posixsubprocess
11469-
+ import select
11470-
+ import selectors
11471-
+ except ModuleNotFoundError:
11472-
+ # iOS *has* subprocesses, but doesn't support them.
11473-
+ _posixsubprocess = None
11474-
else:
11475-
from _winapi import (CREATE_NEW_CONSOLE, CREATE_NEW_PROCESS_GROUP,
11476-
STD_INPUT_HANDLE, STD_OUTPUT_HANDLE,
11477-
@@ -203,7 +207,7 @@
11478-
return "%s(%d)" % (self.__class__.__name__, int(self))
11479-
11480-
__del__ = Close
11481-
-else:
11482-
+elif _posixsubprocess:
11483-
# When select or poll has indicated that the file is writable,
11484-
# we can write up to _PIPE_BUF bytes without risk of blocking.
11485-
# POSIX defines PIPE_BUF as >= 512.
11486-
@@ -231,7 +235,7 @@
11487-
11488-
def _cleanup():
11489-
pass
11490-
-else:
11491-
+elif _posixsubprocess:
11492-
# This lists holds Popen instances for which the underlying process had not
11493-
# exited at the time its __del__ method got called: those processes are
11494-
# wait()ed for synchronously from _cleanup() when a new Popen object is
11495-
@@ -250,6 +254,9 @@
11496-
# This can happen if two threads create a new Popen instance.
11497-
# It's harmless that it was already removed, so ignore.
11498-
pass
11499-
+else:
11500-
+ def _cleanup():
11501-
+ pass
11502-
11503-
PIPE = -1
11504-
STDOUT = -2
11505-
@@ -648,7 +655,7 @@
11506-
Prefer an implementation which can use vfork() in some cases for best
11507-
performance.
11508-
"""
11509-
- if _mswindows or not hasattr(os, 'posix_spawn'):
11510-
+ if _mswindows or _posixsubprocess is None or not hasattr(os, 'posix_spawn'):
11511-
# os.posix_spawn() is not available
11512-
return False
11513-
11514-
@@ -741,6 +748,9 @@
11460+
@@ -741,6 +741,9 @@
1151511461
restore_signals=True, start_new_session=False,
1151611462
pass_fds=(), *, encoding=None, errors=None, text=None):
1151711463
"""Create new Popen instance."""
11518-
+ if not _mswindows and _posixsubprocess is None:
11464+
+ if not os.allows_subprocesses:
1151911465
+ raise RuntimeError(f"Subprocesses are not supported on {sys.platform}")
1152011466
+
1152111467
_cleanup()
1152211468
# Held while anything is calling waitpid before returncode has been
1152311469
# updated to prevent clobbering returncode if wait() or poll() are
11524-
@@ -1723,7 +1733,7 @@
11470+
@@ -1723,7 +1726,7 @@
1152511471
raise SubprocessError("Unknown child exit status!")
1152611472

1152711473

@@ -11530,7 +11476,7 @@ index d4d04a5c34..b742063be5 100644
1153011476
_WNOHANG=os.WNOHANG, _ECHILD=errno.ECHILD):
1153111477
"""Check if child process has terminated. Returns returncode
1153211478
attribute.
11533-
@@ -1732,6 +1742,8 @@
11479+
@@ -1732,6 +1735,8 @@
1153411480
outside of the local scope (nor can any methods it calls).
1153511481

1153611482
"""

patch/Python/Setup.embedded

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ _multiprocessing _multiprocessing/multiprocessing.c _multiprocessing/semaphore.c
3636
_opcode _opcode.c
3737
_operator _operator.c
3838
_pickle _pickle.c -DPy_BUILD_CORE
39+
_posixsubprocess _posixsubprocess.c
3940
_queue _queuemodule.c
4041
_random _randommodule.c
4142
_sha1 sha1module.c

patch/Python/Setup.macOS

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ _decimal _decimal/_decimal.c \
3737
-DCONFIG_64=1 -DANSI=1 -DHAVE_UINT128_T=1
3838

3939
_posixshmem -I$(srcdir)/Modules/_multiprocessing _multiprocessing/posixshmem.c
40-
_posixsubprocess _posixsubprocess.c
4140

4241
_scproxy _scproxy.c -framework SystemConfiguration -framework CoreFoundation
4342

tests/testbed/src/testbed/app.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ def main():
4848
print(f"{sys_platform}: {test.__name__}", end="...")
4949
test()
5050
print(" ok")
51-
except Exception as e:
51+
except Exception:
5252
failures += 1
5353
print(" FAILED!")
5454
print("-" * 80)
55-
traceback.print_exception(e)
55+
traceback.print_exc()
5656
print("-" * 80)
5757

5858
print("=" * 80)

0 commit comments

Comments
 (0)