1
0
Fork 0
forked from github/pelican

Merge pull request #2621 from Lucas-C/fix_module_import_caching_bug

Fix pelican.settings.load_source to avoid caching issues
This commit is contained in:
Justin Mayer 2019-09-23 11:17:09 -07:00 committed by GitHub
commit ce87857104
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

3
RELEASE.md Normal file
View file

@ -0,0 +1,3 @@
Release type: patch
Fix pelican.settings.load_source to avoid caching issues - PR #2621

View file

@ -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