From 0350bed8fd29bf75a610182e6083a90977c21480 Mon Sep 17 00:00:00 2001 From: Alex Cepoi Date: Fri, 31 Aug 2012 16:43:04 +0200 Subject: [PATCH] parse command: fix crash in case of bad callback --- scrapy/commands/parse.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scrapy/commands/parse.py b/scrapy/commands/parse.py index 3e01c771d..a1b7849f1 100644 --- a/scrapy/commands/parse.py +++ b/scrapy/commands/parse.py @@ -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']