loading multiple module with same name using importlib.machinery.SourceFileLoader
ulf.worsoe at mosek.com
ulf.worsoe at mosek.com
Mon May 2 05:28:00 EDT 2016
I have observed this behaviour, for some reason only on OS X (and Python 3.5.1): I use importlib.machinery.SourceFileLoader to load a long list of modules. The modules are not located in the loader path, and many of them have the same name, i.e. I would have:
m1 = importlib.machinery.SourceFileLoader("Module","path/to/m1/Module.py")
m2 = importlib.machinery.SourceFileLoader("Module","path/to/m2/Module.py")
Sometimes the modules will contain members from other modules with the same name, e.g. m1/module.py would define a function "m1func" that does not exist in m2/module.py, but the function would appear in m2, and examining m2.m1func.__code__.co_filename shows that it comes from m1. Members that are defined in both m1 and m2 are not overwritten, though.
Is this a bug in importlib.machinery.SourceFileLoader or are we in the Land of Undefined Behaviour here?
More information about the Python-list
mailing list