改變大小有它發送崇高插件RuntimeError:字典中迭代
postdata = {"some" : "value"}
user_headesr = Config.get_headers() //returning static class variable
requests.post(url, data=json.dumps(postdata), headers=user_headers)
一類,但我得到的錯誤
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 535, in run_
return self.run()
File "~Library/Application Support/Sublime Text 3/Packages/MyPlugin/compile_code.py", line 22, in run
compile_response = hr.send_code_to_server(code, HackerRankConfig.language)
File "~Library/Application Support/Sublime Text 3/Packages/MyPlugin/plugin/hackerrank.py", line 15, in send_code_to_server
resp = requests.post(HackerRankConfig.compile_tests_url, data=json.dumps(postdata), headers=user_headers)
File "~Library/Application Support/Sublime Text 3/Packages/MyPlugin/requests/requests/api.py", line 109, in post
return request('post', url, data=data, json=json, **kwargs)
File "~Library/Application Support/Sublime Text 3/Packages/MyPlugin/requests/requests/api.py", line 50, in request
response = session.request(method=method, url=url, **kwargs)
File "~Library/Application Support/Sublime Text 3/Packages/MyPlugin/requests/requests/sessions.py", line 455, in request
prep = self.prepare_request(req)
File "~Library/Application Support/Sublime Text 3/Packages/MyPlugin/requests/requests/sessions.py", line 382, in prepare_request
headers=merge_setting(request.headers, self.headers, dict_class=CaseInsensitiveDict),
File "~Library/Application Support/Sublime Text 3/Packages/MyPlugin/requests/requests/sessions.py", line 66, in merge_setting
for (k, v) in merged_setting.items():
File "./collections/abc.py", line 479, in __iter__
File "~Library/Application Support/Sublime Text 3/Packages/MyPlugin/requests/requests/structures.py", line 60, in <genexpr>
return (casedkey for casedkey, mappedvalue in self._store.values())
RuntimeError: dictionary changed size during iteration
我的代碼是不會改變的字典裏,get_headers( )從package.sublime-settings文件讀取。
我試過讓該方法返回副本以確保不會導致問題,仍然存在問題。
我使用python 3.3.3,崇高的文本3
不是錯誤,但是'requests'版本使用的是支持張貼'json'直接使用'請求.post(HackerRankConfig.compile_tests_url,json = postdata,headers = user_headers)'(你不必設置'Co在這種情況下是ntent-Type頭)。 –
這是在最新版本的'requests'中引入的一個錯誤。 –