Python 3.3 HTTP Cookie Error

随声附和 提交于 2019-12-11 09:12:33

问题


I just did a fresh install (from source) of Python 3.3 and I installed the 'requests' library. I'm attempting a very simple request:

r = requests.get('https://www.google.com/')

And I'm getting a very strange error in return:

File "/usr/local/lib/python3.3/http/cookiejar.py", line 1647, in extract_cookies
  if self._policy.set_ok(cookie, request):
File "/usr/local/lib/python3.3/http/cookiejar.py", line 931, in set_ok
  if not fn(cookie, request):
File "/usr/local/lib/python3.3/http/cookiejar.py", line 952, in set_ok_verifiability
  if request.unverifiable and is_third_party(request):
AttributeError: 'MockRequest' object has no attribute 'unverifiable'

Seeing as I'm still somewhat a Python beginner, I have absolutely no idea what is causing this error. Any ideas?


回答1:


This works in python 3.2:

Python 3.2.3 (default, Apr 13 2012, 13:31:19) 
[GCC 4.2.1 Compatible Apple Clang 3.0 (tags/Apple/clang-211.12)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> r = requests.get('https://www.google.com/')

The requests FAQ states python 3 is supported up to version 3.2, and you have just found out on python 3.3, requests does not (yet) work.

There is a patch available in the issue tracker, so it's only a matter of time.

Update: Version 0.14.1 was released on 2012/10/01, with the fix:

0.14.1 (2012-10-01)

  • Python 3.3 Compatibility
  • Simply default accept-encoding
  • Bugfixes


来源:https://stackoverflow.com/questions/12659833/python-3-3-http-cookie-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!