mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
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
|
from pelican.log import LimitFilter
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# SourceFileLoader is the recommended way in Python 3.3+
|
# spec_from_file_location is the recommended way in Python 3.5+
|
||||||
from importlib.machinery import SourceFileLoader
|
import importlib.util
|
||||||
|
|
||||||
def load_source(name, path):
|
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:
|
except ImportError:
|
||||||
# but it does not exist in Python 2.7, so fall back to imp
|
# but it does not exist in Python 2.7, so fall back to imp
|
||||||
import imp
|
import imp
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue