Merge branch '0.12-maintenance'
This commit is contained in:
commit
71c534d2c6
4 changed files with 20 additions and 4 deletions
2
CHANGES
2
CHANGES
|
|
@ -13,6 +13,8 @@ Version 0.12.1
|
||||||
|
|
||||||
Bugfix release, unreleased
|
Bugfix release, unreleased
|
||||||
|
|
||||||
|
- Prevent `flask run` from showing a NoAppException when an ImportError occurs
|
||||||
|
within the imported application module.
|
||||||
- Fix encoding behavior of ``app.config.from_pyfile`` for Python 3. Fix
|
- Fix encoding behavior of ``app.config.from_pyfile`` for Python 3. Fix
|
||||||
``#2118``.
|
``#2118``.
|
||||||
|
|
||||||
|
|
|
||||||
14
flask/cli.py
14
flask/cli.py
|
|
@ -89,10 +89,16 @@ def locate_app(app_id):
|
||||||
try:
|
try:
|
||||||
__import__(module)
|
__import__(module)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise NoAppException('The file/path provided (%s) does not appear to '
|
# Reraise the ImportError if it occurred within the imported module.
|
||||||
'exist. Please verify the path is correct. If '
|
# Determine this by checking whether the trace has a depth > 1.
|
||||||
'app is not on PYTHONPATH, ensure the extension '
|
if sys.exc_info()[-1].tb_next:
|
||||||
'is .py' % module)
|
raise
|
||||||
|
else:
|
||||||
|
raise NoAppException('The file/path provided (%s) does not appear'
|
||||||
|
' to exist. Please verify the path is '
|
||||||
|
'correct. If app is not on PYTHONPATH, '
|
||||||
|
'ensure the extension is .py' % module)
|
||||||
|
|
||||||
mod = sys.modules[module]
|
mod = sys.modules[module]
|
||||||
if app_obj is None:
|
if app_obj is None:
|
||||||
app = find_best_app(mod)
|
app = find_best_app(mod)
|
||||||
|
|
|
||||||
7
tests/test_apps/cliapp/importerrorapp.py
Normal file
7
tests/test_apps/cliapp/importerrorapp.py
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
from __future__ import absolute_import, print_function
|
||||||
|
|
||||||
|
from flask import Flask
|
||||||
|
|
||||||
|
raise ImportError()
|
||||||
|
|
||||||
|
testapp = Flask('testapp')
|
||||||
|
|
@ -83,6 +83,7 @@ def test_locate_app(test_apps):
|
||||||
pytest.raises(NoAppException, locate_app, "notanpp.py")
|
pytest.raises(NoAppException, locate_app, "notanpp.py")
|
||||||
pytest.raises(NoAppException, locate_app, "cliapp/app")
|
pytest.raises(NoAppException, locate_app, "cliapp/app")
|
||||||
pytest.raises(RuntimeError, locate_app, "cliapp.app:notanapp")
|
pytest.raises(RuntimeError, locate_app, "cliapp.app:notanapp")
|
||||||
|
pytest.raises(ImportError, locate_app, "cliapp.importerrorapp")
|
||||||
|
|
||||||
|
|
||||||
def test_find_default_import_path(test_apps, monkeypatch, tmpdir):
|
def test_find_default_import_path(test_apps, monkeypatch, tmpdir):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue