From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 15 Sep 2025 16:29:33 +0000 (+0200) Subject: [3.13] gh-131189: Fix "msvcrt" import warning on Linux when "_ctypes" is not availabl... X-Git-Tag: v3.13.8~75 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7452e95d09e92b00d514cb098680d0c4b80dc5a1;p=thirdparty%2FPython%2Fcpython.git [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 f320c951c3220aa6727b581216463e8b3f8bcd6b) Co-authored-by: Dzmitry Plashchynski --- diff --git a/Lib/_pyrepl/readline.py b/Lib/_pyrepl/readline.py index be229488e54e..f802a9526909 100644 --- a/Lib/_pyrepl/readline.py +++ b/Lib/_pyrepl/readline.py @@ -42,10 +42,11 @@ from .console import Console as ConsoleType 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"