diff --git a/applications/admin/controllers/pythonanywhere.py b/applications/admin/controllers/pythonanywhere.py index 33dfda6fd..e61b06ab1 100644 --- a/applications/admin/controllers/pythonanywhere.py +++ b/applications/admin/controllers/pythonanywhere.py @@ -4,10 +4,8 @@ import re import gzip import tarfile -from gluon._compat import StringIO -from xmlrpclib import ProtocolError from gluon.contrib.simplejsonrpc import ServerProxy - +from gluon._compat import StringIO, ProtocolError def deploy(): response.title = T('Deploy to pythonanywhere') diff --git a/gluon/_compat.py b/gluon/_compat.py index f7b53dde7..a87a5c943 100644 --- a/gluon/_compat.py +++ b/gluon/_compat.py @@ -31,6 +31,7 @@ from types import ClassType import cgi import cookielib + from xmlrpclib import ProtocolError BytesIO = StringIO reduce = reduce hashlib_md5 = hashlib.md5 @@ -94,6 +95,7 @@ def to_native(obj, charset='utf8', errors='strict'): from urllib.request import FancyURLopener, urlopen from urllib.parse import quote as urllib_quote, unquote as urllib_unquote, urlencode from http import cookiejar as cookielib + from xmlrpc.client import ProtocolError import html # warning, this is the python3 module and not the web2py html module hashlib_md5 = lambda s: hashlib.md5(bytes(s, 'utf8')) iterkeys = lambda d: iter(d.keys()) diff --git a/gluon/contrib/simplejsonrpc.py b/gluon/contrib/simplejsonrpc.py index 2a4547f7a..f60dc4c75 100644 --- a/gluon/contrib/simplejsonrpc.py +++ b/gluon/contrib/simplejsonrpc.py @@ -17,12 +17,17 @@ __license__ = "LGPL 3.0" __version__ = "0.05" +import sys +PY2 = sys.version_info[0] == 2 import urllib -from xmlrpclib import Transport, SafeTransport -from cStringIO import StringIO +if PY2: + from xmlrpclib import Transport, SafeTransport + from cStringIO import StringIO +else: + from xmlrpc.client import Transport, SafeTransport + from io import StringIO import random -import sys import json