Skip to content

Commit 7d70b27

Browse files
committed
Merge branch 'dev' into 3.9
2 parents 11a0cba + deded81 commit 7d70b27

File tree

6 files changed

+12
-65
lines changed

6 files changed

+12
-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
@@ -699,7 +699,7 @@ index f3828b10e1..7e86539bfa 100644
699699
+ _CASE_INSENSITIVE_PLATFORMS_STR_KEY)
700700

701701
diff --git a/Lib/os.py b/Lib/os.py
702-
index b794159f86..449cf932b6 100644
702+
index b794159f86..78aab1ea2a 100644
703703
--- a/Lib/os.py
704704
+++ b/Lib/os.py
705705
@@ -36,7 +36,7 @@
@@ -716,7 +716,7 @@ index b794159f86..449cf932b6 100644
716716
del _fscodec
717717

718718
+
719-
+if sys.platform in ('iOS', 'tvos', 'watchos'):
719+
+if sys.platform in ('ios', 'tvos', 'watchos'):
720720
+ allows_subprocesses = False
721721
+else:
722722
+ allows_subprocesses = True
@@ -834,74 +834,20 @@ index 9e617afb00..41305298d3 100644
834834
return f'{userbase}/lib/python{version[0]}.{version[1]}/site-packages'
835835

836836
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
837-
index 4effc1d8b3..70e69c2379 100644
837+
index 4effc1d8b3..b0e4a5acac 100644
838838
--- a/Lib/subprocess.py
839839
+++ b/Lib/subprocess.py
840-
@@ -75,9 +75,13 @@
841-
_mswindows = True
842-
except ModuleNotFoundError:
843-
_mswindows = False
844-
- import _posixsubprocess
845-
- import select
846-
- import selectors
847-
+ try:
848-
+ import _posixsubprocess
849-
+ import select
850-
+ import selectors
851-
+ except ModuleNotFoundError:
852-
+ # iOS *has* subprocesses, but doesn't support them.
853-
+ _posixsubprocess = None
854-
else:
855-
from _winapi import (CREATE_NEW_CONSOLE, CREATE_NEW_PROCESS_GROUP,
856-
STD_INPUT_HANDLE, STD_OUTPUT_HANDLE,
857-
@@ -212,7 +216,7 @@
858-
return "%s(%d)" % (self.__class__.__name__, int(self))
859-
860-
__del__ = Close
861-
-else:
862-
+elif _posixsubprocess:
863-
# When select or poll has indicated that the file is writable,
864-
# we can write up to _PIPE_BUF bytes without risk of blocking.
865-
# POSIX defines PIPE_BUF as >= 512.
866-
@@ -240,7 +244,7 @@
867-
868-
def _cleanup():
869-
pass
870-
-else:
871-
+elif _posixsubprocess:
872-
# This lists holds Popen instances for which the underlying process had not
873-
# exited at the time its __del__ method got called: those processes are
874-
# wait()ed for synchronously from _cleanup() when a new Popen object is
875-
@@ -259,6 +263,9 @@
876-
# This can happen if two threads create a new Popen instance.
877-
# It's harmless that it was already removed, so ignore.
878-
pass
879-
+else:
880-
+ def _cleanup():
881-
+ pass
882-
883-
PIPE = -1
884-
STDOUT = -2
885-
@@ -660,7 +667,7 @@
886-
Prefer an implementation which can use vfork() in some cases for best
887-
performance.
888-
"""
889-
- if _mswindows or not hasattr(os, 'posix_spawn'):
890-
+ if _mswindows or _posixsubprocess is None or not hasattr(os, 'posix_spawn'):
891-
# os.posix_spawn() is not available
892-
return False
893-
894-
@@ -762,6 +769,9 @@
840+
@@ -762,6 +762,9 @@
895841
pass_fds=(), *, user=None, group=None, extra_groups=None,
896842
encoding=None, errors=None, text=None, umask=-1):
897843
"""Create new Popen instance."""
898-
+ if not _mswindows and _posixsubprocess is None:
844+
+ if not os.allows_subprocesses:
899845
+ raise RuntimeError(f"Subprocesses are not supported on {sys.platform}")
900846
+
901847
_cleanup()
902848
# Held while anything is calling waitpid before returncode has been
903849
# updated to prevent clobbering returncode if wait() or poll() are
904-
@@ -1834,7 +1844,7 @@
850+
@@ -1834,7 +1837,7 @@
905851
else:
906852
self.returncode = waitstatus_to_exitcode(sts)
907853

@@ -910,7 +856,7 @@ index 4effc1d8b3..70e69c2379 100644
910856
_WNOHANG=os.WNOHANG, _ECHILD=errno.ECHILD):
911857
"""Check if child process has terminated. Returns returncode
912858
attribute.
913-
@@ -1843,6 +1853,8 @@
859+
@@ -1843,6 +1846,8 @@
914860
outside of the local scope (nor can any methods it calls).
915861

916862
"""

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_MODULE
39+
_posixsubprocess _posixsubprocess.c
3940
_queue _queuemodule.c
4041
_random _randommodule.c -DPy_BUILD_CORE_MODULE
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/pyproject.toml

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ requires = [
2121
"std-nslog",
2222
]
2323
support_package = "../../dist/Python-3.9-macOS-support.custom.tar.gz"
24+
template = "../../../../templates/briefcase-macOS-Xcode-template"
2425

2526
[tool.briefcase.app.testbed.linux]
2627
supported = false
@@ -35,6 +36,7 @@ requires = [
3536
"std-nslog",
3637
]
3738
support_package = "../../dist/Python-3.9-iOS-support.custom.tar.gz"
39+
template = "../../../../templates/briefcase-iOS-Xcode-template"
3840

3941
[tool.briefcase.app.testbed.android]
4042
supported = false

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)