Python 3.3 HTTP Cookie Error

2019-07-31 07:31发布

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条回答
仙女界的扛把子
2楼-- · 2019-07-31 08:26

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
查看更多
登录 后发表回答