From b82e17e626f7b1cd98aada0b1ebb65cb9f8fb184 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Thu, 23 May 2019 08:45:22 -0700 Subject: bpo-36842: Implement PEP 578 (GH-12613) Adds sys.audit, sys.addaudithook, io.open_code, and associated C APIs. --- Python/import.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'Python/import.c') diff --git a/Python/import.c b/Python/import.c index c634edb4c7f..ec172b29f73 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1661,6 +1661,17 @@ import_find_and_load(PyObject *abs_name) _PyTime_t t1 = 0, accumulated_copy = accumulated; + PyObject *sys_path = PySys_GetObject("path"); + PyObject *sys_meta_path = PySys_GetObject("meta_path"); + PyObject *sys_path_hooks = PySys_GetObject("path_hooks"); + if (PySys_Audit("import", "OOOOO", + abs_name, Py_None, sys_path ? sys_path : Py_None, + sys_meta_path ? sys_meta_path : Py_None, + sys_path_hooks ? sys_path_hooks : Py_None) < 0) { + return NULL; + } + + /* XOptions is initialized after first some imports. * So we can't have negative cache before completed initialization. * Anyway, importlib._find_and_load is much slower than -- cgit v1.2.3