You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Value of the python.languageServer setting: Microsoft Python Language Server version 0.5.45.0
Expected behaviour
Debug as usual.
Actual behaviour
Debugger is messed up: Running lines of code one or two steps later or crash the python interpreter with errors that make no sense at all.
The interesting thing is that if i use print("foo") the debugger works fine again. If I remove the print() the debugger messes up again.
I´m not 100 per cent sure that this issue is vscode related but maybe my wrong implementation of code.
defparse(self, response):
url=response.request.urlnamed_references= {}
text=""text_div=content.css('div.storywrapper div.sectionZ div.con div.modCon div.modParagraph')
fortagintext_div:
nodes=tag.xpath('./node()')
nodes_name=nodes.xpath('name()').get()
fornodeinnodes:
child_nodes=node.xpath('./node()')
forcinchild_nodes:
#print('debugger works again, if i uncomment this')#most of the time node_name is executed one line later than it shouldnode_name=c.xpath('name()').get()
ifnode_name=='a':
href=c.xpath('@href').get() #relative href#if the debugger / python interpreter crashes totally, it happens herenamed_references[c.xpath('text()').get().strip('\n') ifc.xpath('text()').get() isnotNoneelse'unknown'] =href#save the link in the dict, key is the text (if it exists)yieldresponse.follow(c, callback=self.parseArticle)
elifnode_name==None:
text+=c.get().strip('\n')
yield {'url': url, 'named_references': named_references, 'text': text}
Run Spider with scrapy crawl __spidername__
Logs
Here is an example of the messed up debugger:
forxinarticle_item['named_references']: #line 113, setting x to a keyref_url=article_item['named_references'][x]
yieldresponse.follow(article_item['named_references'][x], callback=self.parseArticle) #this is line 115
File ".../spiders/tagesschau_spider.py", line 115, in parseArticle yield response.follow(article_item['named_references'][x], callback=self.parseArticle) UnboundLocalError: local variable 'x' referenced before assignment
The text was updated successfully, but these errors were encountered:
It was written by me. named_references is a dictionary containing hyperlinks from articles:
named_references= { "The german football Bundesliga": "https://www.bundesliga.com/de/bundesliga", "German champion 2020 is Bayern Munich": "https://www.faz.net/aktuell/sport/fussball/bundesliga/fussball-bundesliga-bayern-muenchen-ist-deutscher-meister-2020-16809640.html"}
I then iterate over each key-value pair and crawl the url listed in each key-value pair.
Environment data
"python.jediEnabled"
set to; more info How to update the language server to the latest stable version vscode-python#3977): XXXpython.languageServer
setting: Microsoft Python Language Server version 0.5.45.0Expected behaviour
Debug as usual.
Actual behaviour
Debugger is messed up: Running lines of code one or two steps later or crash the python interpreter with errors that make no sense at all.
The interesting thing is that if i use print("foo") the debugger works fine again. If I remove the print() the debugger messes up again.
I´m not 100 per cent sure that this issue is vscode related but maybe my wrong implementation of code.
Steps to reproduce:
scrapy crawl __spidername__
Logs
Here is an example of the messed up debugger:
File ".../spiders/tagesschau_spider.py", line 115, in parseArticle yield response.follow(article_item['named_references'][x], callback=self.parseArticle) UnboundLocalError: local variable 'x' referenced before assignment
The text was updated successfully, but these errors were encountered: