Browse Source

Remove the imported app module from sys.modules on SyntaxError

When a SyntaxError occurrs in a package's `__init__.py` file, Python
seems to leave an empty module in `sys.modules`. This will result in any
request after the first to give you a `NoAppException` instead of the
`SyntaxError` again.

Fixes #2423
pull/2588/head
Segev Finer 7 years ago
parent
commit
e83bcc6290
  1. 5
      flask/cli.py

5
flask/cli.py

@ -215,6 +215,11 @@ def locate_app(script_info, module_name, app_name, raise_if_not_found=True):
)
else:
return
except SyntaxError:
if module_name in sys.modules:
del sys.modules[module_name]
raise
module = sys.modules[module_name]

Loading…
Cancel
Save