Skip to content

Comments

gh-145076: Validate type inputs in __lazy_import__#145088

Closed
andresliszt wants to merge 1 commit intopython:mainfrom
andresliszt:gh-issue-145076
Closed

gh-145076: Validate type inputs in __lazy_import__#145088
andresliszt wants to merge 1 commit intopython:mainfrom
andresliszt:gh-issue-145076

Conversation

@andresliszt
Copy link

@andresliszt andresliszt commented Feb 21, 2026

Hello! first of all, thanks for this amazing project! best in the world. This is my very first attempt of contribution to cpython. This PR aims to fix the issue #145076, by adding validators to inputs in lazy_import

@bedevere-app
Copy link

bedevere-app bot commented Feb 21, 2026

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.

@andresliszt andresliszt force-pushed the gh-issue-145076 branch 3 times, most recently from 3db62fc to 3d5d090 Compare February 21, 2026 19:24
PyObject *builtins;
PyThreadState *tstate = PyThreadState_GET();

// Validate input arguments
Copy link
Member

@picnixz picnixz Feb 21, 2026

Choose a reason for hiding this comment

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

Quick suggestion: check that we accept the same input types as PyImport_ImportModuleLevelObject does. I assume that __import__ and __lazy_import__ should behave similarly. I don't know if this is already the case with your PR but you could also refactor the logic of that validation in a single function that would be used in PyImport_ImportModuleLevelObject as well (so that we have similar error messages) (or just cc the logic).

@picnixz
Copy link
Member

picnixz commented Feb 21, 2026

Are those changes actually necessary now that #145086 is merged?

@picnixz picnixz added the pending The issue will be closed if no feedback is provided label Feb 21, 2026
@StanFromIreland
Copy link
Member

Yes the SystemError is no longer raised. This PR also duplicates checks in _PyImport_LazyImportModuleLevelObject.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review pending The issue will be closed if no feedback is provided

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants