From 6829d160507ee80030c4ab66a22b07c9d0e51b25 Mon Sep 17 00:00:00 2001 From: Haibo Lin Date: Jan 11 2024 05:41:00 +0000 Subject: Fix compatibility with Python 3.12 The imp module is deprecated since 3.4 and will be removed in 3.12 in favor of importlib. Signed-off-by: Haibo Lin --- diff --git a/cts/config.py b/cts/config.py index f3e400d..fe2911e 100644 --- a/cts/config.py +++ b/cts/config.py @@ -22,10 +22,11 @@ # # Written by Jan Kaluza -import imp import os import sys +from importlib.machinery import SourceFileLoader + from cts import logger @@ -82,7 +83,9 @@ def init_config(app): # try loading configuration from file if not config_module: try: - config_module = imp.load_source("cts_runtime_config", config_file) + config_module = SourceFileLoader( + "cts_runtime_config", config_file + ).load_module() except Exception: raise SystemError( "Configuration file {} was not found.".format(config_file)