mirror of https://github.com/python/cpython
gh-90473: Fail subprocess early on Emscripten/WASI (GH-92802)
This commit is contained in:
parent
d923fdf54b
commit
db0b455ff4
|
@ -74,6 +74,9 @@ except ModuleNotFoundError:
|
||||||
else:
|
else:
|
||||||
_mswindows = True
|
_mswindows = True
|
||||||
|
|
||||||
|
# wasm32-emscripten and wasm32-wasi do not support processes
|
||||||
|
_can_fork_exec = sys.platform not in {"emscripten", "wasi"}
|
||||||
|
|
||||||
if _mswindows:
|
if _mswindows:
|
||||||
import _winapi
|
import _winapi
|
||||||
from _winapi import (CREATE_NEW_CONSOLE, CREATE_NEW_PROCESS_GROUP,
|
from _winapi import (CREATE_NEW_CONSOLE, CREATE_NEW_PROCESS_GROUP,
|
||||||
|
@ -97,13 +100,10 @@ if _mswindows:
|
||||||
"CREATE_NO_WINDOW", "DETACHED_PROCESS",
|
"CREATE_NO_WINDOW", "DETACHED_PROCESS",
|
||||||
"CREATE_DEFAULT_ERROR_MODE", "CREATE_BREAKAWAY_FROM_JOB"])
|
"CREATE_DEFAULT_ERROR_MODE", "CREATE_BREAKAWAY_FROM_JOB"])
|
||||||
else:
|
else:
|
||||||
if sys.platform in {"emscripten", "wasi"}:
|
if _can_fork_exec:
|
||||||
def _fork_exec(*args, **kwargs):
|
|
||||||
raise OSError(
|
|
||||||
errno.ENOTSUP, f"{sys.platform} does not support processes."
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
from _posixsubprocess import fork_exec as _fork_exec
|
from _posixsubprocess import fork_exec as _fork_exec
|
||||||
|
else:
|
||||||
|
_fork_exec = None
|
||||||
import select
|
import select
|
||||||
import selectors
|
import selectors
|
||||||
|
|
||||||
|
@ -801,6 +801,11 @@ class Popen:
|
||||||
encoding=None, errors=None, text=None, umask=-1, pipesize=-1,
|
encoding=None, errors=None, text=None, umask=-1, pipesize=-1,
|
||||||
process_group=None):
|
process_group=None):
|
||||||
"""Create new Popen instance."""
|
"""Create new Popen instance."""
|
||||||
|
if not _can_fork_exec:
|
||||||
|
raise OSError(
|
||||||
|
errno.ENOTSUP, f"{sys.platform} does not support processes."
|
||||||
|
)
|
||||||
|
|
||||||
_cleanup()
|
_cleanup()
|
||||||
# Held while anything is calling waitpid before returncode has been
|
# Held while anything is calling waitpid before returncode has been
|
||||||
# updated to prevent clobbering returncode if wait() or poll() are
|
# updated to prevent clobbering returncode if wait() or poll() are
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
:mod:`subprocess` now fails early on Emscripten and WASI platforms to work
|
||||||
|
around missing :func:`os.pipe` on WASI.
|
Loading…
Reference in New Issue