[WIP] Handle cases when inspect.stack() fails #582
Conversation
I think we shouldn't merge it without a test case. |
can we add a valid testcase without installing jinja2? |
It sems that this fails because jinja2 does some heavy magic with python code frames. Installing jinja2 looks easier than trying to find out what is this magic and how to replicate it. |
but if jinja2 (or any other library) stops doing its bad magic the bug won't be properly tested. We want to test that when inspect.stack fails it won't panic for users. |
We can just mock inspect.stack to raise an exception then. I was thinking of adding jinja2 test because I haven't reproduced this issue myself yet. To reproduce it I was going to make a small example with jinja2, and why not put it to the testing suite then? |
Adding jinja2 to scrapy's dependency (even if just test) seems too much to me. I have tried to reproduce that myself too but couldn't either till now. |
I personally don't care much about testing dependencies - they are installed automatically by tox or by travis, why should we worry about adding some extra ones? |
well, is more work for travis too where jinja2 (and its deps) will be I am cool with testing by mocking inspect.stack On Wed, Feb 5, 2014 at 3:07 PM, Mikhail Korobov notifications@github.comwrote:
|
[WIP] Handle cases when inspect.stack() fails
Ricardo @panaggio reported an error: creating BaseSpider class fails if the first import is inside jinja2 template. Stacktrace:
lines
list contain lines of jinja2 template, not the python source code in this case, and it looks like inspect.stack() gets confused. In this PR such errors are catched and converted to warnings.