Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError from contract errback #3370

Closed
StasDeep opened this issue Aug 9, 2018 · 1 comment
Closed

AttributeError from contract errback #3370

StasDeep opened this issue Aug 9, 2018 · 1 comment

Comments

@StasDeep
Copy link
Contributor

StasDeep commented Aug 9, 2018

When running a contract with a URL that returns non-200 response, I get the following:

2018-08-09 14:40:23 [scrapy.core.scraper] ERROR: Spider error processing <GET https://www.bureauxlocaux.com/annonce/a-louer-bureaux-a-louer-a-nantes--1289-358662> (referer: None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/twisted/internet/defer.py", line 653, in _runCallbacks
    current.result = callback(current.result, *args, **kw)
  File "/usr/local/lib/python3.6/site-packages/scrapy/contracts/__init__.py", line 89, in eb_wrapper
    results.addError(case, exc_info)
  File "/usr/local/lib/python3.6/unittest/runner.py", line 67, in addError
    super(TextTestResult, self).addError(test, err)
  File "/usr/local/lib/python3.6/unittest/result.py", line 17, in inner
    return method(self, *args, **kw)
  File "/usr/local/lib/python3.6/unittest/result.py", line 115, in addError
    self.errors.append((test, self._exc_info_to_string(err, test)))
  File "/usr/local/lib/python3.6/unittest/result.py", line 186, in _exc_info_to_string
    exctype, value, tb, limit=length, capture_locals=self.tb_locals)
  File "/usr/local/lib/python3.6/traceback.py", line 470, in __init__
    exc_value.__cause__.__traceback__,
AttributeError: 'getset_descriptor' object has no attribute '__traceback__'

Here is how exc_info looks like:

(HttpError('Ignoring non-200 response',), <class 'scrapy.spidermiddlewares.httperror.HttpError'>, <traceback object at 0x7f4bdca1d948>)
@StasDeep
Copy link
Contributor Author

StasDeep commented Aug 9, 2018

I've found the bug. It's inside scrapy/contracts/__init__.py.

Here's how exc_info is initialized:

exc_info = failure.value, failure.type, failure.getTracebackObject()

So we get (value, type, traceback) tuple. But it must be (type, value, traceback).

I'll create a PR with a fix soon.

lopuhin added a commit that referenced this issue Aug 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant