Scrapy, a fast high-level web crawling & scraping framework for Python.
replaced DeprecationWarning by a new ScrapyDeprecationWarning category, since the default DeprecationWarning is silenced on Python 2.7+
Pablo Hoffman0eaa1d95f6de
diff --git a/scrapy/cmdline.py b/scrapy/cmdline.pyindex e381bf537..4ff61fd86 100644--- a/scrapy/cmdline.py+++ b/scrapy/cmdline.py@@ -11,7 +11,7 @@ from scrapy.crawler import CrawlerProcessfrom scrapy.xlib import lsprofcalltreefrom scrapy.conf import settingsfrom scrapy.command import ScrapyCommand-from scrapy.exceptions import UsageError+from scrapy.exceptions import UsageError, ScrapyDeprecationWarningfrom scrapy.utils.misc import walk_modulesfrom scrapy.utils.project import inside_project@@ -82,7 +82,7 @@ def _check_deprecated_scrapy_ctl(argv, inproject):returnimport warningswarnings.warn("`scrapy-ctl.py` command-line tool is deprecated and will be removed in Scrapy 0.11, use `scrapy` instead",- DeprecationWarning, stacklevel=3)+ ScrapyDeprecationWarning, stacklevel=3)if inproject:projpath = os.path.abspath(os.path.dirname(os.path.dirname(settings.settings_module.__file__)))cfg_path = os.path.join(projpath, 'scrapy.cfg')diff --git a/scrapy/contrib/closespider.py b/scrapy/contrib/closespider.pyindex fed26e84a..7dab6c55f 100644--- a/scrapy/contrib/closespider.py+++ b/scrapy/contrib/closespider.py@@ -12,6 +12,7 @@ from twisted.python import log as txlogfrom scrapy.xlib.pydispatch import dispatcherfrom scrapy import signals, log+from scrapy.exceptions import ScrapyDeprecationWarningfrom scrapy.project import crawlerfrom scrapy.conf import settings@@ -22,7 +23,7 @@ class CloseSpider(object):self.itemcount = settings.getint('CLOSESPIDER_ITEMCOUNT')# XXX: legacy support - remove for future releasesif settings.getint('CLOSESPIDER_ITEMPASSED'):- warnings.warn("CLOSESPIDER_ITEMPASSED setting is deprecated, use CLOSESPIDER_ITEMCOUNT instead", DeprecationWarning)+ warnings.warn("CLOSESPIDER_ITEMPASSED setting is deprecated, use CLOSESPIDER_ITEMCOUNT instead", ScrapyDeprecationWarning)self.pagecount = settings.getint('CLOSESPIDER_ITEMPASSED')self.pagecount = settings.getint('CLOSESPIDER_PAGECOUNT')self.errorcount = settings.getint('CLOSESPIDER_ERRORCOUNT')diff --git a/scrapy/contrib/exporter/jsonlines.py b/scrapy/contrib/exporter/jsonlines.pyindex eb2dbcafe..fbab65735 100644--- a/scrapy/contrib/exporter/jsonlines.py+++ b/scrapy/contrib/exporter/jsonlines.py@@ -1,5 +1,6 @@from scrapy.contrib.exporter import JsonLinesItemExporter+from scrapy.exceptions import ScrapyDeprecationWarningimport warningswarnings.warn("Module `scrapy.contrib.exporter.jsonlines` is deprecated - use `scrapy.contrib.exporter` instead",- DeprecationWarning, stacklevel=2)+ ScrapyDeprecationWarning, stacklevel=2)diff --git a/scrapy/contrib/spidermiddleware/depth.py b/scrapy/contrib/spidermiddleware/depth.pyindex 883d828ee..978e7baef 100644--- a/scrapy/contrib/spidermiddleware/depth.py+++ b/scrapy/contrib/spidermiddleware/depth.py@@ -8,6 +8,7 @@ import warningsfrom scrapy import logfrom scrapy.http import Request+from scrapy.exceptions import ScrapyDeprecationWarningclass DepthMiddleware(object):@@ -27,7 +28,7 @@ class DepthMiddleware(object):# XXX: backwards compatibility with old SCHEDULER_ORDER setting# will be removed on Scrapy 0.15warnings.warn("SCHEDULER_ORDER setting is deprecated, " \- "use DEPTH_PRIORITY instead", DeprecationWarning)+ "use DEPTH_PRIORITY instead", ScrapyDeprecationWarning)if sorder == 'BFO':prio = 1elif sorder == 'DFO':diff --git a/scrapy/core/downloader/__init__.py b/scrapy/core/downloader/__init__.pyindex f39da779f..cd60d4d83 100644--- a/scrapy/core/downloader/__init__.py+++ b/scrapy/core/downloader/__init__.py@@ -11,6 +11,7 @@ from scrapy.utils.defer import mustbe_deferredfrom scrapy.utils.signal import send_catch_logfrom scrapy.utils.httpobj import urlparse_cachedfrom scrapy.resolver import dnscache+from scrapy.exceptions import ScrapyDeprecationWarningfrom scrapy import signalsfrom scrapy import logfrom .middleware import DownloaderMiddlewareManager@@ -46,7 +47,7 @@ def _get_concurrency_delay(concurrency, spider, settings):c = settings.getint('CONCURRENT_REQUESTS_PER_SPIDER')if c:warnings.warn("CONCURRENT_REQUESTS_PER_SPIDER setting is deprecated, " \- "use CONCURRENT_REQUESTS_PER_DOMAIN instead", DeprecationWarning)+ "use CONCURRENT_REQUESTS_PER_DOMAIN instead", ScrapyDeprecationWarning)concurrency = c# ----------------------------diff --git a/scrapy/exceptions.py b/scrapy/exceptions.pyindex 43e142160..8f29a4c8d 100644--- a/scrapy/exceptions.py+++ b/scrapy/exceptions.py@@ -43,3 +43,10 @@ class UsageError(Exception):def __init__(self, *a, **kw):self.print_help = kw.pop('print_help', True)super(UsageError, self).__init__(*a, **kw)++class ScrapyDeprecationWarning(Warning):+ """Warning category for deprecated features, since the default+ DeprecationWarning is silenced on Python 2.7++ """+ pass+diff --git a/scrapy/http/common.py b/scrapy/http/common.pyindex 63d264264..34d5389bf 100644--- a/scrapy/http/common.py+++ b/scrapy/http/common.py@@ -1,9 +1,10 @@import warnings+from scrapy.exceptions import ScrapyDeprecationWarningdef deprecated_setter(setter, attrname):def newsetter(self, value):c = self.__class__.__name__warnings.warn("Don't modify %s.%s attribute, use %s.replace() instead" % \- (c, attrname, c), DeprecationWarning, stacklevel=2)+ (c, attrname, c), ScrapyDeprecationWarning, stacklevel=2)return setter(self, value)return newsetterdiff --git a/scrapy/log.py b/scrapy/log.pyindex 6285209ce..8d79f3aef 100644--- a/scrapy/log.py+++ b/scrapy/log.py@@ -13,6 +13,7 @@ import scrapyfrom scrapy.conf import settingsfrom scrapy.utils.python import unicode_to_strfrom scrapy.utils.misc import load_object+from scrapy.exceptions import ScrapyDeprecationWarning# Logging levelsDEBUG = logging.DEBUG@@ -114,7 +115,7 @@ def start(logfile=None, loglevel=None, logstdout=None):def msg(message, level=INFO, **kw):if 'component' in kw:warnings.warn("Argument `component` of scrapy.log.msg() is deprecated", \- DeprecationWarning, stacklevel=2)+ ScrapyDeprecationWarning, stacklevel=2)kw.setdefault('system', 'scrapy')kw['logLevel'] = levellog.msg(message, **kw)diff --git a/scrapy/utils/decorator.py b/scrapy/utils/decorator.pyindex 54edebc85..623736577 100644--- a/scrapy/utils/decorator.py+++ b/scrapy/utils/decorator.py@@ -3,6 +3,7 @@ from functools import wrapsfrom twisted.internet import defer, threads+from scrapy.exceptions import ScrapyDeprecationWarningdef deprecated(use_instead=None):"""This is a decorator which can be used to mark functions@@ -15,7 +16,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(message, category=DeprecationWarning, stacklevel=2)+ warnings.warn(message, category=ScrapyDeprecationWarning, stacklevel=2)return func(*args, **kwargs)return new_funcreturn wrappeddiff --git a/scrapy/utils/deprecate.py b/scrapy/utils/deprecate.pyindex 58f580259..a5850b6e8 100644--- a/scrapy/utils/deprecate.py+++ b/scrapy/utils/deprecate.py@@ -2,8 +2,10 @@import warnings+from scrapy.exceptions import ScrapyDeprecationWarning+def attribute(obj, oldattr, newattr, version='0.12'):cname = obj.__class__.__name__warnings.warn("%s.%s attribute is deprecated and will be no longer supported ""in Scrapy %s, use %s.%s attribute instead" % \- (cname, oldattr, version, cname, newattr), DeprecationWarning, stacklevel=3)+ (cname, oldattr, version, cname, newattr), ScrapyDeprecationWarning, stacklevel=3)