jsonrpclib icon indicating copy to clipboard operation
jsonrpclib copied to clipboard

Using this library with Python 3.x

Open SajidSalim opened this issue 7 years ago • 5 comments

Can this library be supported to work for Python 3.x if certain issues are fixed? The following are the basic issues I have found. There are no compilation issues.

jsonrpc.py: from xmlrpclib becomes from xmlrpc.client. from httplib import HTTP, HTTPConnection becomes from http.client import HTTPConnection

SimpleJSONRPCServer.py: SimpleXMLRPCServer becomes xmlrpc.server ServerSocket becomes serversocket Line 62: except Exception, e: becomes except Exception as e:

Any other changes I am missing?

SajidSalim avatar Apr 21 '17 13:04 SajidSalim

The xmlrpclib module has been renamed to xmlrpc.client in Python 3.

See Python2 xmlrpclib

This project has not been updated for two years, so you can find this file

jsonrpc.py and change

from xmlrpclib import Transport as XMLTransport
from xmlrpclib import SafeTransport as XMLSafeTransport
from xmlrpclib import ServerProxy as XMLServerProxy
from xmlrpclib import _Method as XML_Method

to

from xmlrpc.client import Transport as XMLTransport
from xmlrpc.client import SafeTransport as XMLSafeTransport
from xmlrpc.client import ServerProxy as XMLServerProxy
from xmlrpc.client import _Method as XML_Method 

bkda avatar May 03 '17 03:05 bkda

I am after the same thing. I've got it working in Python 3.5.2 (win10) with all tests passing, but have broken it for 2.7 (linux) which I'm looking into now. There's a bit more to the changes than those listed above.

prs247au avatar May 13 '17 05:05 prs247au

You can use 2to3 to convert the source file:

2to3 -w jsonrpc.py

This will do the above for you. Then change manually these two lines:

line 168 from http.client import HTTP, HTTPConnection
line 186     class UnixHTTP(HTTP):

To

line 168 from http.client import HTTPConnection
line 186     class UnixHTTP(HTTPConnection):

The best option is however to switch to jsonrpclib-pelix which supports Python3

tony-bony avatar Mar 29 '21 23:03 tony-bony

@SajidSalim / @tony-bony / @prs247au I know it is several years since you posted, but this should be resolved in 0.2.1 on PyPI for Python 3.5+. Please let me know if there are other issues (assuming you are still using something like this library), otherwise I will close the issue.

joshmarshall avatar Apr 02 '21 05:04 joshmarshall