[3.13] gh-131189: Fix "msvcrt" import warning on Linux when "_ctypes" is not available. (GH-131201) (GH-138934)

gh-131189: Fix "msvcrt" import warning on Linux when "_ctypes" is not available. (GH-131201)

Fix "msvcrt" import warning on Linux when "_ctypes" is not available.

On Linux, compiling without "libffi" causes a
"No module named 'msvcrt'" warning when launching PyREPL.
(cherry picked from commit f320c951c3)

Co-authored-by: Dzmitry Plashchynski <plashchynski@gmail.com>
This commit is contained in:
Miss Islington (bot) 2025-09-15 18:29:33 +02:00 committed by GitHub
parent dbe5e3925b
commit 7452e95d09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -42,10 +42,11 @@
Console: type[ConsoleType]
_error: tuple[type[Exception], ...] | type[Exception]
try:
from .unix_console import UnixConsole as Console, _error
except ImportError:
if os.name == "nt":
from .windows_console import WindowsConsole as Console, _error
else:
from .unix_console import UnixConsole as Console, _error
ENCODING = sys.getdefaultencoding() or "latin1"