bpo-40280: Change subprocess imports for cleaner error on wasm32 (GH-30620)
This commit is contained in:
parent
91e33ac3d0
commit
7f4b69b907
@ -65,16 +65,11 @@ __all__ = ["Popen", "PIPE", "STDOUT", "call", "check_call", "getstatusoutput",
|
|||||||
# NOTE: We intentionally exclude list2cmdline as it is
|
# NOTE: We intentionally exclude list2cmdline as it is
|
||||||
# considered an internal implementation detail. issue10838.
|
# considered an internal implementation detail. issue10838.
|
||||||
|
|
||||||
try:
|
_mswindows = sys.platform == "win32"
|
||||||
|
|
||||||
|
if _mswindows:
|
||||||
import msvcrt
|
import msvcrt
|
||||||
import _winapi
|
import _winapi
|
||||||
_mswindows = True
|
|
||||||
except ModuleNotFoundError:
|
|
||||||
_mswindows = False
|
|
||||||
import _posixsubprocess
|
|
||||||
import select
|
|
||||||
import selectors
|
|
||||||
else:
|
|
||||||
from _winapi import (CREATE_NEW_CONSOLE, CREATE_NEW_PROCESS_GROUP,
|
from _winapi import (CREATE_NEW_CONSOLE, CREATE_NEW_PROCESS_GROUP,
|
||||||
STD_INPUT_HANDLE, STD_OUTPUT_HANDLE,
|
STD_INPUT_HANDLE, STD_OUTPUT_HANDLE,
|
||||||
STD_ERROR_HANDLE, SW_HIDE,
|
STD_ERROR_HANDLE, SW_HIDE,
|
||||||
@ -95,6 +90,10 @@ else:
|
|||||||
"NORMAL_PRIORITY_CLASS", "REALTIME_PRIORITY_CLASS",
|
"NORMAL_PRIORITY_CLASS", "REALTIME_PRIORITY_CLASS",
|
||||||
"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:
|
||||||
|
import _posixsubprocess
|
||||||
|
import select
|
||||||
|
import selectors
|
||||||
|
|
||||||
|
|
||||||
# Exception classes used by this module.
|
# Exception classes used by this module.
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
:mod:`subprocess` now imports Windows-specific imports when
|
||||||
|
``sys.platform == "win32"`` and POSIX-specific imports on all other
|
||||||
|
platforms. This gives a clean exception when ``_posixsubprocess`` is not
|
||||||
|
available (e.g. Emscripten browser target) and it's slightly faster, too.
|
Loading…
x
Reference in New Issue
Block a user