]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-131189: Fix "msvcrt" import warning on Linux when "_ctypes" is not availabl...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 15 Jul 2025 08:12:45 +0000 (10:12 +0200)
committerGitHub <noreply@github.com>
Tue, 15 Jul 2025 08:12:45 +0000 (10:12 +0200)
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 f320c951c3220aa6727b581216463e8b3f8bcd6b)

Co-authored-by: Dzmitry Plashchynski <plashchynski@gmail.com>
Lib/_pyrepl/readline.py

index 9560ae779abfea24894f79f8177c01311fb1966f..23b8fa6b9c7625e4f0de0365e99408211553f992 100644 (file)
@@ -43,10 +43,11 @@ from ._module_completer import ModuleCompleter, make_default_module_completer
 
 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"