Skip to content

Commit

Permalink
Show line which caused the DeprecationWarning (#1831)
Browse files Browse the repository at this point in the history
When raising a DeprecationWarning, show the line in the application code
which caused the warning, rather than the line in Flask

e.g. a file `app.py` with:

```python
from flask import Flask
from flask.ext.babel import Babel
```

will show:

```
app.py:2: ExtDeprecationWarning: Importing flask.ext.babel is
deprecated, use flask_babel instead.
```

instead of:

```
/home/mapleoin/venv/local/lib/python2.7/site-packages/flask/exthook.py:71: ExtDeprecationWarning: Importing flask.ext.babel is deprecated, use flask_babel instead.
  .format(x=modname), ExtDeprecationWarning
```
  • Loading branch information
Ionuț Arțăriși authored and davidism committed May 29, 2016
1 parent 70de011 commit ba07f5b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion flask/exthook.py
Expand Up @@ -68,7 +68,7 @@ def load_module(self, fullname):

warnings.warn(
"Importing flask.ext.{x} is deprecated, use flask_{x} instead."
.format(x=modname), ExtDeprecationWarning
.format(x=modname), ExtDeprecationWarning, stacklevel=2
)

for path in self.module_choices:
Expand Down

0 comments on commit ba07f5b

Please sign in to comment.