Commit dd4dfee3 authored by Victor Stinner's avatar Victor Stinner Committed by GitHub

Make load_dynamic() compatible with Python 3.10 (GH-4045)

Backport code from the master branch:

* commit 4e785d42
* commit a9fb7768
parent 7d1dc885
......@@ -35,14 +35,18 @@ if sys.version_info[0] < 3:
else:
to_unicode = lambda x: x
if sys.version_info[:2] < (3, 3):
if sys.version_info < (3, 5):
import imp
def load_dynamic(name, module_path):
return imp.load_dynamic(name, module_path)
else:
from importlib.machinery import ExtensionFileLoader
import importlib.util as _importlib_util
def load_dynamic(name, module_path):
return ExtensionFileLoader(name, module_path).load_module()
spec = _importlib_util.spec_from_file_location(name, module_path)
module = _importlib_util.module_from_spec(spec)
# sys.modules[name] = module
spec.loader.exec_module(module)
return module
class UnboundSymbols(EnvTransform, SkipDeclarations):
def __init__(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment