使用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
答案 0 :(得分:2)
将python从2.7.9升级到2.7.10解决了这个问题。