summaryrefslogtreecommitdiffstats
path: root/Lib/subprocess.py
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2022-01-17 06:23:36 (GMT)
committerGitHub <noreply@github.com>2022-01-17 06:23:36 (GMT)
commit7f4b69b9076bdbcea31f6ad16eb125ee99cf0175 (patch)
treebca8970e65dbc9489ac1033eb2ddd56d6ef728c5 /Lib/subprocess.py
parent91e33ac3d08a1c6004c469da2c0e2a97b5bdc53c (diff)
downloadcpython-7f4b69b9076bdbcea31f6ad16eb125ee99cf0175.zip
cpython-7f4b69b9076bdbcea31f6ad16eb125ee99cf0175.tar.gz
cpython-7f4b69b9076bdbcea31f6ad16eb125ee99cf0175.tar.bz2
bpo-40280: Change subprocess imports for cleaner error on wasm32 (GH-30620)
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r--Lib/subprocess.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 33f022f..358f49a 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -65,16 +65,11 @@ __all__ = ["Popen", "PIPE", "STDOUT", "call", "check_call", "getstatusoutput",
# NOTE: We intentionally exclude list2cmdline as it is
# considered an internal implementation detail. issue10838.
-try:
+_mswindows = sys.platform == "win32"
+
+if _mswindows:
import msvcrt
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,
STD_INPUT_HANDLE, STD_OUTPUT_HANDLE,
STD_ERROR_HANDLE, SW_HIDE,
@@ -95,6 +90,10 @@ else:
"NORMAL_PRIORITY_CLASS", "REALTIME_PRIORITY_CLASS",
"CREATE_NO_WINDOW", "DETACHED_PROCESS",
"CREATE_DEFAULT_ERROR_MODE", "CREATE_BREAKAWAY_FROM_JOB"])
+else:
+ import _posixsubprocess
+ import select
+ import selectors
# Exception classes used by this module.