TypeError: __init__() got an unexpected keyword argument 'check_hostname' in GAE with https
TypeError: __init__() got an unexpected keyword argument 'check_hostname' in GAE with https
我在使用gae时出现如下错误:
TypeError: __init__() got an unexpected keyword argument 'check_hostname'
堆栈跟踪:
File "C:\Dev\PycharmProjects\spiralai\default\src\facebook.py", line 99, in get_object
return self.request(id, args)
File "C:\Dev\PycharmProjects\spiralai\default\src\facebook.py", line 304, in request
urllib.urlencode(args), post_data)
File "C:\Python2764\Lib\urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "C:\Python2764\Lib\urllib2.py", line 431, in open
response = self._open(req, data)
File "C:\Python2764\Lib\urllib2.py", line 449, in _open
'_open', req)
File "C:\Python2764\Lib\urllib2.py", line 409, in _call_chain
result = func(*args)
File "C:\Python2764\Lib\urllib2.py", line 1241, in https_open
context=self._context, check_hostname=self._check_hostname)
File "C:\Python2764\Lib\urllib2.py", line 1166, in do_open
h = http_class(host, timeout=req.timeout, **http_conn_args)
基本上,在连接到 HTTPS 时默认使用 urllib2 时会发生这种情况。 check_hostname 在我的代码中没有使用,它在 urllib2 中。错误是因为 GAE 将 http_class 替换为 google.appengine.dist27.gae_override.httplib.HTTPSConnection 。这显然在 urllib2 中预期的方法中没有这样的参数。
有没有办法解决这个问题?基本上所有使用 urllib2 并连接到 https 的包都根本不起作用。这是荒唐的。
Python 2.7.9 x64 和最新的 GAE
将 python 从 2.7.9 升级到 2.7.10 解决了这个问题。
我在使用gae时出现如下错误:
TypeError: __init__() got an unexpected keyword argument 'check_hostname'
堆栈跟踪:
File "C:\Dev\PycharmProjects\spiralai\default\src\facebook.py", line 99, in get_object
return self.request(id, args)
File "C:\Dev\PycharmProjects\spiralai\default\src\facebook.py", line 304, in request
urllib.urlencode(args), post_data)
File "C:\Python2764\Lib\urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "C:\Python2764\Lib\urllib2.py", line 431, in open
response = self._open(req, data)
File "C:\Python2764\Lib\urllib2.py", line 449, in _open
'_open', req)
File "C:\Python2764\Lib\urllib2.py", line 409, in _call_chain
result = func(*args)
File "C:\Python2764\Lib\urllib2.py", line 1241, in https_open
context=self._context, check_hostname=self._check_hostname)
File "C:\Python2764\Lib\urllib2.py", line 1166, in do_open
h = http_class(host, timeout=req.timeout, **http_conn_args)
基本上,在连接到 HTTPS 时默认使用 urllib2 时会发生这种情况。 check_hostname 在我的代码中没有使用,它在 urllib2 中。错误是因为 GAE 将 http_class 替换为 google.appengine.dist27.gae_override.httplib.HTTPSConnection 。这显然在 urllib2 中预期的方法中没有这样的参数。 有没有办法解决这个问题?基本上所有使用 urllib2 并连接到 https 的包都根本不起作用。这是荒唐的。 Python 2.7.9 x64 和最新的 GAE
将 python 从 2.7.9 升级到 2.7.10 解决了这个问题。