aboutsummaryrefslogtreecommitdiffstats
path: root/library/python/runtime/importer.pxi
diff options
context:
space:
mode:
authorkuzmich321 <kuzmich321@yandex-team.com>2023-11-24 13:22:03 +0300
committerkuzmich321 <kuzmich321@yandex-team.com>2023-11-24 14:17:53 +0300
commit850c48ccf9cadbf8096c6b5015e064c38d0d912e (patch)
tree6428205563111f7cb02bd9af8c158654fb95b197 /library/python/runtime/importer.pxi
parentc5284478af104d82c4d84a5d99bf0a51ecd2ca63 (diff)
downloadydb-850c48ccf9cadbf8096c6b5015e064c38d0d912e.tar.gz
Python Import Tracing
Diffstat (limited to 'library/python/runtime/importer.pxi')
-rw-r--r--library/python/runtime/importer.pxi9
1 files changed, 7 insertions, 2 deletions
diff --git a/library/python/runtime/importer.pxi b/library/python/runtime/importer.pxi
index ba6c422bde..43e6456856 100644
--- a/library/python/runtime/importer.pxi
+++ b/library/python/runtime/importer.pxi
@@ -241,8 +241,13 @@ class ResourceImporter(object):
old_mod = sys.modules.get(mod_name, None)
sys.modules[mod_name] = mod
+ # __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 = mod.__name__
+ initial_filename = mod.__file__
+
if self._before_import_callback:
- self._before_import_callback(mod)
+ self._before_import_callback(initial_modname, initial_filename)
try:
exec code in mod.__dict__
@@ -252,7 +257,7 @@ class ResourceImporter(object):
# "Zero-cost". Just in case import error occurs
if self._after_import_callback:
- self._after_import_callback(mod)
+ self._after_import_callback(initial_modname, initial_filename)
# Some hacky modules (e.g. pygments.lexers) replace themselves in
# `sys.modules` with proxies.