Fix deprecation warning for use of the imp module

This commit is contained in:
Chris Mayo 2020-08-10 19:32:04 +01:00
parent a977e4d712
commit 658c8051f0

View file

@ -10,7 +10,7 @@ import os
import sys
import zipfile
import importlib
import imp
from .fileutil import is_writable_by_others
@ -67,7 +67,10 @@ def get_folder_modules(folder, parentpackage):
fullname = os.path.join(folder, filename)
modname = parentpackage + "." + filename[:-3]
try:
yield imp.load_source(modname, fullname)
spec = importlib.util.spec_from_file_location(modname, fullname)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
yield module
except ImportError as msg:
print("WARN: could not load file %s: %s" % (fullname, msg))