Skip to content

Commit 5e14c56

Browse files
authored
Merge pull request #632 from htcondor/V24_x-HTCONDOR-2688-fix-module-load
HTCONDOR-2688 fix-module-load
2 parents 9f818b4 + 31b50bc commit 5e14c56

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

Diff for: src/htcondorce/web.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11

22
import os
33
import re
4-
import importlib
4+
import importlib.machinery
5+
import importlib.util
56
import json
67
import time
78
import logging
@@ -114,7 +115,10 @@ def check_initialized(environ):
114115
if not filename.endswith(".py"):
115116
continue
116117
name = filename[:-3]
117-
plugin = importlib.load_source(name, os.path.join(plugins_dir, filename))
118+
loader = importlib.machinery.SourceFileLoader(name, os.path.join(plugins_dir, filename))
119+
spec = importlib.util.spec_from_loader(loader.name, loader)
120+
plugin = importlib.util.module_from_spec(spec)
121+
loader.exec_module(plugin)
118122
if validate_plugin(name, plugin):
119123
log.debug("plugin %s: loaded ok", name)
120124
_plugins.append(plugin)

Diff for: tests/test_condor_ce_router_defaults.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
loader = importlib.machinery.SourceFileLoader('condor_ce_router_defaults', DEFAULTS_PATH)
1515
spec = importlib.util.spec_from_loader(loader.name, loader)
1616
defaults = importlib.util.module_from_spec(spec)
17-
loader.exec(defaults)
17+
loader.exec_module(defaults)
1818

1919
class TestDefaults(unittest.TestCase):
2020
"""Unit tests for condor_ce_router_defaults"""

Diff for: tests/test_verify_ce_config.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/usr/bin/python3
22
"""Unit tests for verify_ce_config.py"""
33

4-
import importlib
4+
import importlib.machinery
5+
import importlib.util
56
import os
67
import unittest
78

@@ -36,7 +37,10 @@
3637
'''
3738

3839
VERIFY_PATH = os.path.join('..', 'src', 'verify_ce_config.py')
39-
verify = importlib.load_source('verify_ce_config', VERIFY_PATH)
40+
loader = importlib.machinery.SourceFileLoader('verify_ce_config', VERIFY_PATH)
41+
spec = importlib.util.spec_from_loader(loader.name, loader)
42+
verify = importlib.util.module_from_spec(spec)
43+
loader.exec_module(verify)
4044

4145

4246
class TestVerifyConfig(unittest.TestCase):

0 commit comments

Comments
 (0)