Scrapy, a fast high-level web crawling & scraping framework for Python.
revert warning filter on deprecated class instantiation
Daniel Graña8c81d6c6a9d9
diff --git a/scrapy/tests/test_utils_deprecate.py b/scrapy/tests/test_utils_deprecate.pyindex 1d434512c..b255ca601 100644--- a/scrapy/tests/test_utils_deprecate.py+++ b/scrapy/tests/test_utils_deprecate.py@@ -99,11 +99,13 @@ class WarnWhenSubclassedTest(unittest.TestCase):self.assertEqual(len(w), 1)assert issubclass(w[0].category, MyWarning)+ # warns once instantations in the same linenowith warnings.catch_warnings(record=True) as w:- _i1 = Deprecated()- _i2 = Deprecated()+ for _ in range(10):+ _i1 = Deprecated()+ _i2 = Deprecated()- self.assertEqual(len(w), 1)+ self.assertEqual(len(w), 2)assert issubclass(w[0].category, MyWarning)def test_warning_auto_message(self):diff --git a/scrapy/utils/deprecate.py b/scrapy/utils/deprecate.pyindex d4e5b835e..252a1eb53 100644--- a/scrapy/utils/deprecate.py+++ b/scrapy/utils/deprecate.py@@ -49,7 +49,6 @@ def create_deprecated_class(name, new_class, clsdict=None,deprecated_class = Nonewarned_on_subclass = False- warned_on_instance = Falsedef __new__(metacls, name, bases, clsdict_):cls = super(DeprecatedClass, metacls).__new__(metacls, name, bases, clsdict_)@@ -86,8 +85,7 @@ def create_deprecated_class(name, new_class, clsdict=None,def __call__(cls, *args, **kwargs):meta = cls.__class__old = meta.deprecated_class- if (cls is old) and not (warn_once and meta.warned_on_instance):- meta.warned_on_instance = True+ if cls is old:msg = instance_warn_message.format(cls=_clspath(cls),new=_clspath(new_class))warnings.warn(msg, warn_category, stacklevel=2)