From ba07f5bd81f66a40333cc619d0a8a7b3c17ec49f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionu=C8=9B=20Ar=C8=9B=C4=83ri=C8=99i?= Date: Sun, 29 May 2016 22:51:05 +0100 Subject: [PATCH] Show line which caused the DeprecationWarning (#1831) 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 ``` --- flask/exthook.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flask/exthook.py b/flask/exthook.py index 6522e0636a..d88428027a 100644 --- a/flask/exthook.py +++ b/flask/exthook.py @@ -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: