FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-40280: Use presence of msvcrt module to detect Windows by tiran · Pull Request #30930 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
9 changes: 7 additions & 2 deletions Lib/subprocess.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,15 @@
# 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,
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
:mod:`subprocess` now imports Windows-specific imports when
``sys.platform == "win32"`` and POSIX-specific imports on all other
``msvcrt`` module is available, 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.
available (e.g. Emscripten browser target).

Back | FazBrowse Home | New Git URL