diff options
author | Lucas Cimon <lucas.cimon@gmail.com> | 2019-09-23 17:48:56 +0200 |
---|---|---|
committer | Lucas Cimon <lucas.cimon@gmail.com> | 2019-09-23 20:06:41 +0200 |
commit | 367245cc47e9acae03e06f37de088551165154c7 (patch) | |
tree | 4ab0555457327d8ace8b6e9d9e799461a684e863 | |
parent | 7f4e614bb8f7f43b8419c896ee0cd1bedd4e0a9c (diff) | |
download | pelican-367245cc47e9acae03e06f37de088551165154c7.tar.gz |
Fix pelican.settings.load_source to avoid caching issues
-rw-r--r-- | RELEASE.md | 3 | ||||
-rw-r--r-- | pelican/settings.py | 10 |
2 files changed, 10 insertions, 3 deletions
diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 00000000..5c1ba5d3 --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,3 @@ +Release type: patch + +Fix pelican.settings.load_source to avoid caching issues - PR #2621 diff --git a/pelican/settings.py b/pelican/settings.py index a957b26c..4aa31afe 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -14,12 +14,16 @@ import six from pelican.log import LimitFilter + try: - # SourceFileLoader is the recommended way in Python 3.3+ - from importlib.machinery import SourceFileLoader + # spec_from_file_location is the recommended way in Python 3.5+ + import importlib.util def load_source(name, path): - return SourceFileLoader(name, path).load_module() + spec = importlib.util.spec_from_file_location(name, path) + mod = importlib.util.module_from_spec(spec) + spec.loader.exec_module(mod) + return mod except ImportError: # but it does not exist in Python 2.7, so fall back to imp import imp |