Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

add response arg to item_dropped signal handlers #710

Rafal Jagoda9d226e626683
diff --git a/docs/topics/signals.rst b/docs/topics/signals.rst
index eea7c64ca..b881352f8 100644
--- a/docs/topics/signals.rst
+++ b/docs/topics/signals.rst
@@ -83,7 +83,7 @@ item_dropped
------------
.. signal:: item_dropped
-.. function:: item_dropped(item, exception, spider)
+.. function:: item_dropped(item, response, exception, spider)
Sent after an item has been dropped from the :ref:`topics-item-pipeline`
when some stage raised a :exc:`~scrapy.exceptions.DropItem` exception.
@@ -96,6 +96,9 @@ item_dropped
:param spider: the spider which scraped the item
:type spider: :class:`~scrapy.spider.Spider` object
+ :param response: the response from where the item was dropped
+ :type response: :class:`~scrapy.http.Response` object
+
:param exception: the exception (which must be a
:exc:`~scrapy.exceptions.DropItem` subclass) which caused the item
to be dropped
diff --git a/scrapy/core/scraper.py b/scrapy/core/scraper.py
index bc9979928..e5120ec0d 100644
--- a/scrapy/core/scraper.py
+++ b/scrapy/core/scraper.py
@@ -205,7 +205,7 @@ class Scraper(object):
logkws = self.logformatter.dropped(item, ex, response, spider)
log.msg(spider=spider, **logkws)
return self.signals.send_catch_log_deferred(signal=signals.item_dropped, \
- item=item, spider=spider, exception=output.value)
+ item=item, response=response, spider=spider, exception=output.value)
else:
log.err(output, 'Error processing %s' % item, spider=spider)
else: