summarylogtreecommitdiffstats
path: root/mongodb-5.0.31-python12.patch
blob: 5a9da2e45aa8b44915a91cde55165039e4335fdc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
diff --git a/buildscripts/moduleconfig.py b/buildscripts/moduleconfig.py
index b4d0bba0..a928e9b5 100644
--- a/buildscripts/moduleconfig.py
+++ b/buildscripts/moduleconfig.py
@@ -27,7 +27,7 @@ MongoDB SConscript files do.
 __all__ = ('discover_modules', 'discover_module_directories', 'configure_modules',
            'register_module_test')  # pylint: disable=undefined-all-variable
 
-import imp
+import importlib.util
 import inspect
 import os
 
@@ -71,12 +71,18 @@ def discover_modules(module_root, allowed_modules):
             print("adding module: %s" % (name))
             fp = open(build_py, "r")
             try:
-                module = imp.load_module("module_" + name, fp, build_py,
-                                         (".py", "r", imp.PY_SOURCE))
-                if getattr(module, "name", None) is None:
-                    module.name = name
-                found_modules.append(module)
-                found_module_names.append(name)
+                module_name = "module_" + name
+                spec = importlib.util.spec_from_file_location(module_name, build_py)
+
+                if spec is not None:
+                    module = importlib.util.module_from_spec(spec)
+                    spec.loader.exec_module(module)
+
+                    if getattr(module, "name", None) is None:
+                        module.name = name
+
+                    found_modules.append(module)
+                    found_module_names.append(name)
             finally:
                 fp.close()
         except (FileNotFoundError, IOError):