Skip to content

Commit

Permalink
fix py3 xmlrpc imports, close web2py#1473
Browse files Browse the repository at this point in the history
  • Loading branch information
ilvalle committed Sep 25, 2016
1 parent b4acfd0 commit 4468355
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 1 addition & 3 deletions applications/admin/controllers/pythonanywhere.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 2 additions & 0 deletions gluon/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from types import ClassType
import cgi
import cookielib
from xmlrpclib import ProtocolError
BytesIO = StringIO
reduce = reduce
hashlib_md5 = hashlib.md5
Expand Down Expand Up @@ -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())
Expand Down
11 changes: 8 additions & 3 deletions gluon/contrib/simplejsonrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 4468355

Please sign in to comment.