4371 shaares
I met a very strange Python module loading behaviour in Pelican today :
https://github.com/getpelican/pelican/blob/3395e71/pelican/settings.py#L21
Here is some minimal code reproducing the issue. It requires 5 files :
bug_repro.py
dir_a/__init__.py
dir_a/test_data/pelicanconf.py
dir_b/__init__.py
dir_b/test_data/pelicanconf.py
bug_repro.py
contains:
import dir_a
import dir_b
dir_a/__init__.py
and dir_b/__init__.py
both contain this code:
import os
from importlib.machinery import SourceFileLoader
print(SourceFileLoader('pelicanconf', os.path.dirname(__file__) + '/test_data/pelicanconf.py').load_module().THEME)
dir_a/test_data/pelicanconf.py
contains only the line THEME = 'localized_theme'
and dir_b/test_data/pelicanconf.py
is empty.
What will produces python3.7 bug_repro.py
? 😉