Merge pull request #390 from return42/fix-312

[fix] don't mix loaded modules with imported modules (sys.modules)
dependabot/pip/master/sphinx-6.1.3
Alexandre Flament 3 years ago committed by GitHub
commit adeb084cf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
import sys
import re
import importlib
@ -427,13 +426,10 @@ def match_language(locale_code, lang_list=[], custom_aliases={}, fallback='en-US
def load_module(filename, module_dir):
modname = splitext(filename)[0]
if modname in sys.modules:
del sys.modules[modname]
filepath = join(module_dir, filename)
# and https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
spec = importlib.util.spec_from_file_location(modname, filepath)
module = importlib.util.module_from_spec(spec)
sys.modules[modname] = module
spec.loader.exec_module(module)
return module

Loading…
Cancel
Save