gh-138310: Adds sys.audit event for import_module (#138311)

* Updates sys.audit calls for imports to include import_module
* Adds unit tests for existing and new functionality
This commit is contained in:
Lisa Roach 2025-09-19 06:21:42 -07:00 committed by GitHub
parent 7257b24140
commit 2fd43a1ffe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 98 additions and 27 deletions

View file

@ -1307,6 +1307,14 @@ def _sanity_check(name, package, level):
def _find_and_load_unlocked(name, import_):
path = None
sys.audit(
"import",
name,
path,
getattr(sys, "path", None),
getattr(sys, "meta_path", None),
getattr(sys, "path_hooks", None)
)
parent = name.rpartition('.')[0]
parent_spec = None
if parent: