How to get urllib3 and requests working with jython 2.7 beta 1?

て烟熏妆下的殇ゞ 提交于 2019-12-03 08:10:24
t-8ch

Edit: as of May 2015, the current stable version of requests, 2.7.0, no longer suffers from the original error in Jython --Aprillion


The bug you are facing has been fixed some time ago in the development versions of urllib3 and requests.

As you won't be able to install it as it will blow up pip/easy_install with java.lang.RuntimeException: java.lang.RuntimeException: Class file too large! you have to run it directly from the source tree.

There you can fix the import bug by replacing all of the ssl_wrap_socket stuff at the end of requests/packages/urllib3/util.py with a dummy method like:

def ssl_wrap_socket(sock, keyfile=None, certfile=None, cert_reqs=None,
                    ca_certs=None, server_hostname=None,
                    ssl_version=None):
    raise Error('This is not meant to be called')

(If ssl support is a concern to you: it is broken at the moment anyways)

As jython is missing support for idna you have to remove this too. Go to line 290 of request/models.py and replace 'idna' by 'utf-8'.

So if you don't need to use ssl or idna those steps should work.

Followup: The relevant ssl bug in jython is tracked here: http://bugs.jython.org/issue2016

This problem has been resolved - please use Jython 2.7 beta 4 (or the final release).

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