gh-138310: Adds sys.audit event for import_module#138311
Merged
lisroach merged 8 commits intopython:mainfrom Sep 19, 2025
Merged
gh-138310: Adds sys.audit event for import_module#138311lisroach merged 8 commits intopython:mainfrom
lisroach merged 8 commits intopython:mainfrom
Conversation
lisroach
commented
Sep 3, 2025
AA-Turner
reviewed
Sep 4, 2025
kumaraditya303
approved these changes
Sep 5, 2025
Contributor
Author
|
Sorry for the delay, added a bunch of tests that show some interesting weirdness that (I think) is just the way to import system works, but confirmed things work the way they did before my changes:
|
vstinner
reviewed
Sep 15, 2025
|
facebook-github-bot
pushed a commit
to facebookincubator/cinder
that referenced
this pull request
Sep 29, 2025
Summary: Backport of upstream PR-138311 which adds sys.audit calls for import_module. python/cpython#138311 Reviewed By: itamaro Differential Revision: D83073937 fbshipit-source-id: 3831c0e8ac424142149f2a92a5d9e7dde49a6440
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
sys.audittoimport_module.Added updated unit tests.
Cannot populate the
fileargument because it forces loading of the module and breaks LazyLoader, but the typicalimportstatement audit also populates thefileargument toNoneso this is consistent. The only difference is withimport_modulethe audit is called aftersys.modulesis populate, animportstatement will callsys.auditbefore it is populate. I don't think this will make a difference, but could be wrong.