diff options
author | Christian Heimes <christian@python.org> | 2022-01-27 09:57:43 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-27 09:57:43 (GMT) |
commit | 606e496dd6e2ace298532da200169124c26ae0f2 (patch) | |
tree | c819bcc172b0f23cc2fbc36809c70e308a68ae6c /Lib/subprocess.py | |
parent | 897ce9018775bcd679fb49aa17258f8f6e818e23 (diff) | |
download | cpython-606e496dd6e2ace298532da200169124c26ae0f2.zip cpython-606e496dd6e2ace298532da200169124c26ae0f2.tar.gz cpython-606e496dd6e2ace298532da200169124c26ae0f2.tar.bz2 |
bpo-40280: Use presence of msvcrt module to detect Windows (GH-30930)
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r-- | Lib/subprocess.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py index 358f49a..ad08339 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -65,10 +65,15 @@ __all__ = ["Popen", "PIPE", "STDOUT", "call", "check_call", "getstatusoutput", # NOTE: We intentionally exclude list2cmdline as it is # considered an internal implementation detail. issue10838. -_mswindows = sys.platform == "win32" +# use presence of msvcrt to detect Windows-like platforms (see bpo-8110) +try: + import msvcrt +except ModuleNotFoundError: + _mswindows = False +else: + _mswindows = True if _mswindows: - import msvcrt import _winapi from _winapi import (CREATE_NEW_CONSOLE, CREATE_NEW_PROCESS_GROUP, STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, |