forked from github/pelican
Fix pelican.settings.load_source to avoid caching issues
This commit is contained in:
parent
7f4e614bb8
commit
367245cc47
2 changed files with 10 additions and 3 deletions
3
RELEASE.md
Normal file
3
RELEASE.md
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Release type: patch
|
||||
|
||||
Fix pelican.settings.load_source to avoid caching issues - PR #2621
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue