@@ -707,7 +707,7 @@ index 509f99ae8e..2005b88e94 100644
707707 + _CASE_INSENSITIVE_PLATFORMS_STR_KEY)
708708
709709diff --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
1145611456diff --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 """
0 commit comments