Skip to content

Comments

gh-145031: suggest the module in "python -m module"#145096

Open
Locked-chess-official wants to merge 7 commits intopython:mainfrom
Locked-chess-official:runpy_suggest_module
Open

gh-145031: suggest the module in "python -m module"#145096
Locked-chess-official wants to merge 7 commits intopython:mainfrom
Locked-chess-official:runpy_suggest_module

Conversation

@Locked-chess-official
Copy link
Contributor

@Locked-chess-official Locked-chess-official commented Feb 22, 2026

To reduce the code, I split the function traceback._compute_suggestion_error

Co-authored-by: AN Long <aisk@users.noreply.github.com>
raise error("No module named %s" % mod_name)
message = "No module named %r" % mod_name
if (d := _get_possible_name_list(mod_name)):
from traceback import _calculate_closed_name
Copy link
Member

Choose a reason for hiding this comment

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

Now we don't need to use local imports to defer imports, we can just use lazy imports.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think that using new feature in frozen modules is a good idea. If global lazy imports have some bugs, the users just download the release version will unable to be avoid of it. The lazy imports are more suitable to be in the normal modules.

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.

3 participants