# HG changeset patch # User Mads Kiilerich # Date 2024-07-19 19:38:17 # Node ID 2cd418e377de0d3fda89d356fc8ab67f790f3abd # Parent a5d15a7511a91ca292c383a7125c5729e6e2a293 vcs: replace imp with importlib imp has been dropped in Python 3.12. Mercurial has been changed in a similar way. diff --git a/kallithea/lib/vcs/utils/fakemod.py b/kallithea/lib/vcs/utils/fakemod.py --- a/kallithea/lib/vcs/utils/fakemod.py +++ b/kallithea/lib/vcs/utils/fakemod.py @@ -1,4 +1,4 @@ -import imp +import importlib def create_module(name, path): @@ -7,7 +7,8 @@ def create_module(name, path): as given ``name`` and would contain code read from file at the given ``path`` (it may also be a zip or package containing *__main__* module). """ - module = imp.new_module(name) - module.__file__ = path - exec(compile(open(path, "rb").read(), path, 'exec'), module.__dict__) + + spec = importlib.util.spec_from_file_location('module_name', path) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) return module