Merge pull request #5481 from asottile/minor_py3_cleanup
Use new raise syntax in one case
This commit is contained in:
commit
a24933b0a6
|
@ -149,7 +149,6 @@ def importorskip(modname, minversion=None, reason=None):
|
||||||
|
|
||||||
__tracebackhide__ = True
|
__tracebackhide__ = True
|
||||||
compile(modname, "", "eval") # to catch syntaxerrors
|
compile(modname, "", "eval") # to catch syntaxerrors
|
||||||
import_exc = None
|
|
||||||
|
|
||||||
with warnings.catch_warnings():
|
with warnings.catch_warnings():
|
||||||
# make sure to ignore ImportWarnings that might happen because
|
# make sure to ignore ImportWarnings that might happen because
|
||||||
|
@ -159,12 +158,9 @@ def importorskip(modname, minversion=None, reason=None):
|
||||||
try:
|
try:
|
||||||
__import__(modname)
|
__import__(modname)
|
||||||
except ImportError as exc:
|
except ImportError as exc:
|
||||||
# Do not raise chained exception here(#1485)
|
if reason is None:
|
||||||
import_exc = exc
|
reason = "could not import {!r}: {}".format(modname, exc)
|
||||||
if import_exc:
|
raise Skipped(reason, allow_module_level=True) from None
|
||||||
if reason is None:
|
|
||||||
reason = "could not import {!r}: {}".format(modname, import_exc)
|
|
||||||
raise Skipped(reason, allow_module_level=True)
|
|
||||||
mod = sys.modules[modname]
|
mod = sys.modules[modname]
|
||||||
if minversion is None:
|
if minversion is None:
|
||||||
return mod
|
return mod
|
||||||
|
|
Loading…
Reference in New Issue