mirror of https://github.com/pallets/flask.git
made ImportError verbose in cli.py
This commit is contained in:
parent
b831e8507c
commit
e679a85b80
|
@ -10,6 +10,8 @@ Unreleased
|
|||
removed in Flask 2.1, while remaining compatible with both in
|
||||
2.0.x. Use ``response.request.environ`` instead. :pr:`4341`
|
||||
- Fix type annotation for ``errorhandler`` decorator. :issue:`4295`
|
||||
- Revert a change to the CLI that caused it to hide ``ImportError``
|
||||
tracebacks when importing the application. :issue:`4307`
|
||||
|
||||
|
||||
Version 2.0.2
|
||||
|
|
|
@ -258,15 +258,16 @@ def locate_app(script_info, 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
|
||||
|
||||
|
|
Loading…
Reference in New Issue