diff options
author | kuzmich321 <[email protected]> | 2023-11-24 13:22:03 +0300 |
---|---|---|
committer | kuzmich321 <[email protected]> | 2023-11-24 14:17:53 +0300 |
commit | 850c48ccf9cadbf8096c6b5015e064c38d0d912e (patch) | |
tree | 6428205563111f7cb02bd9af8c158654fb95b197 /library/python/runtime_py3 | |
parent | c5284478af104d82c4d84a5d99bf0a51ecd2ca63 (diff) |
Python Import Tracing
Diffstat (limited to 'library/python/runtime_py3')
-rw-r--r-- | library/python/runtime_py3/importer.pxi | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/library/python/runtime_py3/importer.pxi b/library/python/runtime_py3/importer.pxi index f3b353ef034..56c5e439ec0 100644 --- a/library/python/runtime_py3/importer.pxi +++ b/library/python/runtime_py3/importer.pxi @@ -240,8 +240,13 @@ class ResourceImporter(object): module.__path__= [executable + path_sep + module.__name__.replace('.', path_sep)] # exec(code, module.__dict__) + # __name__ and __file__ could be overwritten after execution + # So these two things are needed if wee want to be consistent at some point + initial_modname = module.__name__ + initial_filename = module.__file__ + if self._before_import_callback: - self._before_import_callback(module) + self._before_import_callback(initial_modname, initial_filename) # “Zero-cost” exceptions are implemented. # The cost of try statements is almost eliminated when no exception is raised @@ -249,7 +254,7 @@ class ResourceImporter(object): _call_with_frames_removed(exec, code, module.__dict__) finally: if self._after_import_callback: - self._after_import_callback(module) + self._after_import_callback(initial_modname, initial_filename) # PEP-302 extension 1 of 3: data loader. def get_data(self, path): |