1
0
Fork 0
forked from github/pelican

Fix pelican.settings.load_source to avoid caching issues

This commit is contained in:
Lucas Cimon 2019-09-23 17:48:56 +02:00
commit 367245cc47
No known key found for this signature in database
GPG key ID: 08DA831E717571EE
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