@@ -707,7 +707,7 @@ index 509f99ae8e..2005b88e94 100644
707
707
+ _CASE_INSENSITIVE_PLATFORMS_STR_KEY)
708
708
709
709
diff --git a/Lib/os.py b/Lib/os.py
710
- index 253cad1a59..b69d814e7a 100644
710
+ index 253cad1a59..b2a6fbfb08 100644
711
711
--- a/Lib/os.py
712
712
+++ b/Lib/os.py
713
713
@@ -34,7 +34,7 @@
@@ -724,7 +724,7 @@ index 253cad1a59..b69d814e7a 100644
724
724
del _fscodec
725
725
726
726
+
727
- +if sys.platform in ('iOS ', 'tvos', 'watchos'):
727
+ +if sys.platform in ('ios ', 'tvos', 'watchos'):
728
728
+ allows_subprocesses = False
729
729
+else:
730
730
+ allows_subprocesses = True
@@ -11454,74 +11454,20 @@ index 9fa21cca38..e346fb4390 100644
11454
11454
return f'{userbase}/lib/python{version[0]}.{version[1]}/site-packages'
11455
11455
11456
11456
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
11457
- index d4d04a5c34..b742063be5 100644
11457
+ index d4d04a5c34..0e76349e81 100644
11458
11458
--- a/Lib/subprocess.py
11459
11459
+++ 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 @@
11515
11461
restore_signals=True, start_new_session=False,
11516
11462
pass_fds=(), *, encoding=None, errors=None, text=None):
11517
11463
"""Create new Popen instance."""
11518
- + if not _mswindows and _posixsubprocess is None :
11464
+ + if not os.allows_subprocesses :
11519
11465
+ raise RuntimeError(f"Subprocesses are not supported on {sys.platform}")
11520
11466
+
11521
11467
_cleanup()
11522
11468
# Held while anything is calling waitpid before returncode has been
11523
11469
# updated to prevent clobbering returncode if wait() or poll() are
11524
- @@ -1723,7 +1733 ,7 @@
11470
+ @@ -1723,7 +1726 ,7 @@
11525
11471
raise SubprocessError("Unknown child exit status!")
11526
11472
11527
11473
@@ -11530,7 +11476,7 @@ index d4d04a5c34..b742063be5 100644
11530
11476
_WNOHANG=os.WNOHANG, _ECHILD=errno.ECHILD):
11531
11477
"""Check if child process has terminated. Returns returncode
11532
11478
attribute.
11533
- @@ -1732,6 +1742 ,8 @@
11479
+ @@ -1732,6 +1735 ,8 @@
11534
11480
outside of the local scope (nor can any methods it calls).
11535
11481
11536
11482
"""
0 commit comments