Skip to content
Myr

Show line which caused the DeprecationWarning (#1831)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

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 ```

authored by Ionuț Arțăriși · committed by David Lord · parent 70de011 · Browse files · 1 file+1 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+1 added−1 removed

  • other:+1 added−1 removed

1 file+1 added−1 removed

modified:flask/exthook.py+1 added-1 removed
66 unmodified lines
67 modname = fullname.split('.', self.prefix_cutoff)[self.prefix_cutoff]6869 warnings.warn(70 "Importing flask.ext.{x} is deprecated, use flask_{x} instead."71 .format(x=modname), ExtDeprecationWarning71 .format(x=modname), ExtDeprecationWarning, stacklevel=272 )7374 for path in self.module_choices:75 realname = path % modname
68 unmodified lines