From 607c6eddf9246adf5150311bf71387bb93719d27 Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 5 Feb 2019 13:34:13 +0000 Subject: [PATCH] Switch to a non-deprecated method of loading files by filename (`importlib.util.spec_from_file_location`) --- src/ModuleManager.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ModuleManager.py b/src/ModuleManager.py index 218e5dc2..8dd6a465 100644 --- a/src/ModuleManager.py +++ b/src/ModuleManager.py @@ -1,4 +1,4 @@ -import enum, gc, glob, imp, io, inspect, os, sys, typing, uuid +import enum, gc, glob, importlib, io, inspect, os, sys, typing, uuid from src import Config, EventManager, Exports, IRCBot, Logging, Timers, utils class ModuleException(Exception): @@ -118,7 +118,9 @@ class ModuleManager(object): raise ModuleNotLoadedWarning("waiting for requirement") import_name = self._import_name(name) - module = imp.load_source(import_name, path) + import_spec = importlib.util.spec_from_file_location(import_name, path) + module = importlib.util.module_from_spec(import_spec) + import_spec.loader.exec_module(module) module_object_pointer = getattr(module, "Module", None) if not module_object_pointer: