Merge branch '2.0.x'

This commit is contained in:
David Lord 2021-11-16 06:30:19 -08:00
commit 6b0c8cdac1
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
4 changed files with 29 additions and 20 deletions

View file

@ -222,15 +222,16 @@ def locate_app(module_name, app_name, raise_if_not_found=True):
try:
__import__(module_name)
except ImportError as e:
except ImportError:
# Reraise the ImportError if it occurred within the imported module.
# Determine this by checking whether the trace has a depth > 1.
if sys.exc_info()[2].tb_next:
raise NoAppException(
f"While importing {module_name!r}, an ImportError was raised."
) from e
f"While importing {module_name!r}, an ImportError was"
f" raised:\n\n{traceback.format_exc()}"
) from None
elif raise_if_not_found:
raise NoAppException(f"Could not import {module_name!r}.") from e
raise NoAppException(f"Could not import {module_name!r}.") from None
else:
return