changeset 9001:2cd418e377de stable

vcs: replace imp with importlib imp has been dropped in Python 3.12. Mercurial has been changed in a similar way.
author Mads Kiilerich <mads@kiilerich.com>
date Fri, 19 Jul 2024 21:38:17 +0200
parents a5d15a7511a9
children f6d470bb8612
files kallithea/lib/vcs/utils/fakemod.py
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/vcs/utils/fakemod.py	Fri Jul 19 23:19:34 2024 +0200
+++ b/kallithea/lib/vcs/utils/fakemod.py	Fri Jul 19 21:38:17 2024 +0200
@@ -1,4 +1,4 @@
-import imp
+import importlib
 
 
 def create_module(name, path):
@@ -7,7 +7,8 @@
     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