EventWatcher: fix __import__ usage by replacing it with importlib (closes #1778)

This commit is contained in:
Carnë Draug
2020-08-27 16:28:38 +01:00
parent 57702fa7df
commit b7912f6754

View File

@@ -16,6 +16,8 @@
A widget and supporting classes for watching the events sent to some other widget.
"""
import importlib
import wx
from wx.lib.mixins.listctrl import CheckListCtrlMixin
@@ -396,9 +398,7 @@ class EventWatcher(wx.Frame):
if dlg.ShowModal() == wx.ID_OK:
modname = dlg.GetValue()
try:
# Passing a non-empty fromlist will cause __import__ to
# return the imported submodule if a dotted name is passed.
module = __import__(modname, fromlist=[0])
module = importlib.import_module(modname)
except ImportError:
wx.MessageBox("Unable to import \"%s\"" % modname,
"Error")