Skip to content

Commit

Permalink
Merge branch 'dev' into 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
freakboy3742 committed May 15, 2022
2 parents 11a0cba + deded81 commit 7d70b27
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 65 deletions.
1 change: 0 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ The following standard library modules are available on macOS, but not the other
Apple platforms:
* curses
* posixshmem
* posixsubprocess

The binaries support x86_64 and arm64 for macOS; arm64 for iOS and appleTV
devices; and arm64_32 for watchOS. It also supports device simulators on both
Expand Down
68 changes: 7 additions & 61 deletions patch/Python/Python.patch
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ index f3828b10e1..7e86539bfa 100644
+ _CASE_INSENSITIVE_PLATFORMS_STR_KEY)

diff --git a/Lib/os.py b/Lib/os.py
index b794159f86..449cf932b6 100644
index b794159f86..78aab1ea2a 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -36,7 +36,7 @@
Expand All @@ -716,7 +716,7 @@ index b794159f86..449cf932b6 100644
del _fscodec

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

diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 4effc1d8b3..70e69c2379 100644
index 4effc1d8b3..b0e4a5acac 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -75,9 +75,13 @@
_mswindows = True
except ModuleNotFoundError:
_mswindows = False
- import _posixsubprocess
- import select
- import selectors
+ try:
+ import _posixsubprocess
+ import select
+ import selectors
+ except ModuleNotFoundError:
+ # iOS *has* subprocesses, but doesn't support them.
+ _posixsubprocess = None
else:
from _winapi import (CREATE_NEW_CONSOLE, CREATE_NEW_PROCESS_GROUP,
STD_INPUT_HANDLE, STD_OUTPUT_HANDLE,
@@ -212,7 +216,7 @@
return "%s(%d)" % (self.__class__.__name__, int(self))

__del__ = Close
-else:
+elif _posixsubprocess:
# When select or poll has indicated that the file is writable,
# we can write up to _PIPE_BUF bytes without risk of blocking.
# POSIX defines PIPE_BUF as >= 512.
@@ -240,7 +244,7 @@

def _cleanup():
pass
-else:
+elif _posixsubprocess:
# This lists holds Popen instances for which the underlying process had not
# exited at the time its __del__ method got called: those processes are
# wait()ed for synchronously from _cleanup() when a new Popen object is
@@ -259,6 +263,9 @@
# This can happen if two threads create a new Popen instance.
# It's harmless that it was already removed, so ignore.
pass
+else:
+ def _cleanup():
+ pass

PIPE = -1
STDOUT = -2
@@ -660,7 +667,7 @@
Prefer an implementation which can use vfork() in some cases for best
performance.
"""
- if _mswindows or not hasattr(os, 'posix_spawn'):
+ if _mswindows or _posixsubprocess is None or not hasattr(os, 'posix_spawn'):
# os.posix_spawn() is not available
return False

@@ -762,6 +769,9 @@
@@ -762,6 +762,9 @@
pass_fds=(), *, user=None, group=None, extra_groups=None,
encoding=None, errors=None, text=None, umask=-1):
"""Create new Popen instance."""
+ if not _mswindows and _posixsubprocess is None:
+ if not os.allows_subprocesses:
+ raise RuntimeError(f"Subprocesses are not supported on {sys.platform}")
+
_cleanup()
# Held while anything is calling waitpid before returncode has been
# updated to prevent clobbering returncode if wait() or poll() are
@@ -1834,7 +1844,7 @@
@@ -1834,7 +1837,7 @@
else:
self.returncode = waitstatus_to_exitcode(sts)

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

"""
Expand Down
1 change: 1 addition & 0 deletions patch/Python/Setup.embedded
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ _multiprocessing _multiprocessing/multiprocessing.c _multiprocessing/semaphore.c
_opcode _opcode.c
_operator _operator.c
_pickle _pickle.c -DPy_BUILD_CORE_MODULE
_posixsubprocess _posixsubprocess.c
_queue _queuemodule.c
_random _randommodule.c -DPy_BUILD_CORE_MODULE
_sha1 sha1module.c
Expand Down
1 change: 0 additions & 1 deletion patch/Python/Setup.macOS
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ _decimal _decimal/_decimal.c \
-DCONFIG_64=1 -DANSI=1 -DHAVE_UINT128_T=1

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

_scproxy _scproxy.c -framework SystemConfiguration -framework CoreFoundation

Expand Down
2 changes: 2 additions & 0 deletions tests/testbed/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ requires = [
"std-nslog",
]
support_package = "../../dist/Python-3.9-macOS-support.custom.tar.gz"
template = "../../../../templates/briefcase-macOS-Xcode-template"

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

[tool.briefcase.app.testbed.android]
supported = false
4 changes: 2 additions & 2 deletions tests/testbed/src/testbed/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ def main():
print(f"{sys_platform}: {test.__name__}", end="...")
test()
print(" ok")
except Exception as e:
except Exception:
failures += 1
print(" FAILED!")
print("-" * 80)
traceback.print_exception(e)
traceback.print_exc()
print("-" * 80)

print("=" * 80)
Expand Down

0 comments on commit 7d70b27

Please sign in to comment.