Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using this library with Python 3.x #58

Open
SajidSalim opened this issue Apr 21, 2017 · 4 comments
Open

Using this library with Python 3.x #58

SajidSalim opened this issue Apr 21, 2017 · 4 comments

Comments

@SajidSalim
Copy link

SajidSalim commented Apr 21, 2017

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 SajidSalim changed the title Note: Python 3.x uses XMLRPC and not XMLRPCLIB Note: Python 3.x uses XMLRPC Apr 21, 2017
@SajidSalim SajidSalim changed the title Note: Python 3.x uses XMLRPC Using this library with Python 3.x Apr 21, 2017
@bkda
Copy link

bkda commented May 3, 2017

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 

@prs247au
Copy link
Contributor

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.

@tony-bony
Copy link

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

@joshmarshall
Copy link
Owner

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants