Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 15, 2025

Conversation

plashchynski
Copy link
Contributor

@plashchynski plashchynski commented Mar 13, 2025

On Linux, compiling without "libffi" causes a misleading warning
"No module named 'msvcrt'" when launching PyREPL.

On Linux, compiling without "libffi" causes a
"No module named 'msvcrt'" warning when launching PyREPL.
@bedevere-app
Copy link

bedevere-app bot commented Mar 13, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot recreate the same setup as you have, can you please share what happens with this change in place?

@plashchynski
Copy link
Contributor Author

@sobolevn steps to reproduce on a fresh Ubuntu Server 24.04.2 setup:

sudo apt install build-essential
git clone https://github.com/python/cpython.git
cd cpython
./configure
make

Then:

./python

shows:

Python 3.14.0a5+ (heads/main:c497f83ad85, Mar 14 2025, 09:42:58) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
warning: can't use pyrepl: No module named 'msvcrt'
>>> 

Here's a full log.

with changes in this PR, it shows the following with the same setup:

Python 3.14.0a5+ (heads/fix_msvcrt_warning_on_linux:56364cef29, Mar 14 2025, 09:49:25) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
warning: can't use pyrepl: No module named '_ctypes'
>>> 

Here's a full log.

warning: can't use pyrepl: No module named 'msvcrt'

this warning is misleading, because msvcrt is available only on NT systems.

warning: can't use pyrepl: No module named '_ctypes'

this warning is consistent with the warning make shows for missing necessary bits:

The necessary bits to build these optional modules were not found:
_bz2                      _ctypes                   _ctypes_test           
_curses                   _curses_panel             _dbm                   
_gdbm                     _hashlib                  _lzma                  
_ssl                      _tkinter                  _uuid                  
readline                  zlib                                             
To find the necessary bits, look in configure.ac and config.log.

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, it is clear now! LGTM. However, I am not the module's maintainer, let's wait for them to make the final decision :)

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ambv ambv merged commit f320c95 into python:main Jul 15, 2025
54 checks passed
@ambv ambv added the needs backport to 3.14 bugs and security fixes label Jul 15, 2025
@miss-islington-app
Copy link

Thanks @plashchynski for the PR, and @ambv for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 15, 2025
…is not available. (pythonGH-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 f320c95)

Co-authored-by: Dzmitry Plashchynski <plashchynski@gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented Jul 15, 2025

GH-136668 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Jul 15, 2025
ambv pushed a commit that referenced this pull request Jul 15, 2025
… is not available. (GH-131201) (GH-136668)

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 f320c95)

Co-authored-by: Dzmitry Plashchynski <plashchynski@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants