Skip to content

Commit 440e446

Browse files
committed
Put loaded modules (plugins) into sys.modules
With this, the plugins are accessible from other modules without requiring an explicit import. This was the default behaviour of the previous pre-3.10 loader. Without this, an import call would re-import the plugin making the first and the second ones different from Python's perspective even if they are both the same. This breaks pickle.
1 parent 0375a6f commit 440e446

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

byexample/init.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ def load_modules(dirnames, cfg):
112112
spec = importer.find_spec(name)
113113
module = importlib.util.module_from_spec(spec)
114114
spec.loader.exec_module(module)
115+
116+
sys.modules[name] = module
115117
except Exception as e:
116118
clog().info(
117119
"From '%s' loading '%s'...failed: %s", path, name, str(e)

0 commit comments

Comments
 (0)