Skip to content

Commit

Permalink
Merge pull request #2621 from Lucas-C/fix_module_import_caching_bug
Browse files Browse the repository at this point in the history
Fix pelican.settings.load_source to avoid caching issues
  • Loading branch information
justinmayer authored Sep 23, 2019
2 parents ac1e07a + 367245c commit ce87857
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Release type: patch

Fix pelican.settings.load_source to avoid caching issues - PR #2621
10 changes: 7 additions & 3 deletions pelican/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@

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
Expand Down

0 comments on commit ce87857

Please sign in to comment.