From 9f1ed6376302d2412ce5bba118e67ce2998c08b7 Mon Sep 17 00:00:00 2001 From: Daniel Grana Date: Mon, 24 Aug 2009 20:27:08 -0300 Subject: [PATCH] report caller's file:lineno of deprecated function instead of file:lineno of deprecated function --- scrapy/utils/decorator.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/scrapy/utils/decorator.py b/scrapy/utils/decorator.py index e49ea1c73..a2840628d 100644 --- a/scrapy/utils/decorator.py +++ b/scrapy/utils/decorator.py @@ -1,3 +1,4 @@ +import sys import warnings from functools import wraps @@ -13,14 +14,7 @@ def deprecated(use_instead=None): message = "Call to deprecated function %s." % func.__name__ if use_instead: message += " Use %s instead." % use_instead - - warnings.warn_explicit(message, - category=DeprecationWarning, - filename=func.func_code.co_filename, - lineno=func.func_code.co_firstlineno + 1, - registry=func.func_globals.setdefault('__warningregistry__', \ - {}), - module_globals=func.func_globals) + warnings.warn(message, category=DeprecationWarning, stacklevel=2) return func(*args, **kwargs) return new_func return wrapped