1
0
mirror of https://github.com/scrapy/scrapy.git synced 2025-02-26 22:04:01 +00:00

parse command: fix crash in case of bad callback

This commit is contained in:
Alex Cepoi 2012-08-31 16:43:04 +02:00
parent 4ec99117d3
commit 0350bed8fd

View File

@ -152,9 +152,14 @@ class Command(ScrapyCommand):
else:
cb = 'parse'
cb = cb if callable(cb) else getattr(self.spider, cb, None)
if not cb:
log.msg('Cannot find callback %r in spider: %s' % (callback, self.spider.name))
if not callable(cb):
cb_method = getattr(self.spider, cb, None)
if callable(cb_method):
cb = cb_method
else:
log.msg('Cannot find callback %r in spider: %s' % \
(cb, self.spider.name), level=log.ERROR)
return
# parse items and requests
depth = response.meta['_depth']