From f93b5fbd618935774387443a7d6ee53b7b81573b Mon Sep 17 00:00:00 2001 From: Raphael Vieira Rossi Date: Fri, 6 Oct 2023 22:30:25 -0300 Subject: [PATCH] changed imp to importlib --- derpconf/config.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/derpconf/config.py b/derpconf/config.py index e093658..6d0fde6 100644 --- a/derpconf/config.py +++ b/derpconf/config.py @@ -13,7 +13,8 @@ import logging from collections import defaultdict from os.path import join, exists, abspath, dirname, isdir -import imp +import importlib +#import imp import six from textwrap import fill @@ -23,6 +24,10 @@ class ConfigurationError(RuntimeError): pass +class Test(object): + pass + + class Config(object): class_defaults = {} class_group_items = defaultdict(list) @@ -94,7 +99,8 @@ def __load_from_path(cls, conf, path): with open(path) as config_file: name = 'configuration' code = config_file.read() - module = imp.new_module(name) + spec = importlib._bootstrap.ModuleSpec(name, None) + module = importlib.util.module_from_spec(spec) six.exec_(code, module.__dict__) @@ -118,7 +124,8 @@ def verify(cls, path): with open(path) as config_file: name = 'configuration' code = config_file.read() - module = imp.new_module(name) + spec = importlib._bootstrap.ModuleSpec(name, None) + module = importlib.util.module_from_spec(spec) six.exec_(code, module.__dict__)