only ever catch ImportError (#69792)

ModuleNotFoundError is a subclass of ImportError but only exists in
Python 3.6 or newer. Instead of doing hacks to be able to catch that on
older Pythons, just always only catch ImportError, which will also catch
ModuleNotFoundError on Python 3.6 or later
This commit is contained in:
Evgeni Golov 2020-06-01 18:01:38 +02:00 committed by GitHub
parent 80f09efd03
commit e10e5fc4ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -50,12 +50,6 @@ try:
except ImportError:
import imp
try:
ModuleNotFoundError
except NameError:
# this was introduced in Python 3.6
ModuleNotFoundError = None
display = Display()
_tombstones = None
@ -493,7 +487,7 @@ class PluginLoader:
# FIXME: there must be cheaper/safer way to do this
try:
pkg = import_module(acr.n_python_package_name)
except (ImportError, ModuleNotFoundError):
except ImportError:
return plugin_load_context.nope('Python package {0} not found'.format(acr.n_python_package_name))
pkg_path = os.path.dirname(pkg.__file__)