summaryrefslogtreecommitdiffstats
path: root/Lib/xmlrpc
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2011-10-30 19:24:40 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2011-10-30 19:24:40 (GMT)
commitf70fd7092df0dd815b15104994ff84592b05b1fb (patch)
treed740225fcebdecd7aa7a88e95045d065d815c950 /Lib/xmlrpc
parent1cebc207ea415f96a56f23b520adddeda3364fdc (diff)
parent93dfee1dfc0bf572d4d9579fd455a72c0c81f148 (diff)
downloadcpython-f70fd7092df0dd815b15104994ff84592b05b1fb.zip
cpython-f70fd7092df0dd815b15104994ff84592b05b1fb.tar.gz
cpython-f70fd7092df0dd815b15104994ff84592b05b1fb.tar.bz2
Merge 3.2
Diffstat (limited to 'Lib/xmlrpc')
-rw-r--r--Lib/xmlrpc/client.py36
-rw-r--r--Lib/xmlrpc/server.py10
2 files changed, 13 insertions, 33 deletions
diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py
index 3cd000a..496b2b5 100644
--- a/Lib/xmlrpc/client.py
+++ b/Lib/xmlrpc/client.py
@@ -85,11 +85,6 @@
# OF THIS SOFTWARE.
# --------------------------------------------------------------------
-#
-# things to look into some day:
-
-# TODO: sort out True/False/boolean issues for Python 2.3
-
"""
An XML-RPC client interface for Python.
@@ -120,8 +115,7 @@ Exported classes:
Exported constants:
- True
- False
+ (none)
Exported functions:
@@ -133,7 +127,8 @@ Exported functions:
name (None if not present).
"""
-import re, time, operator
+import base64
+import time
import http.client
from xml.parsers import expat
import socket
@@ -230,7 +225,7 @@ class ResponseError(Error):
##
# Indicates an XML-RPC fault response package. This exception is
# raised by the unmarshalling layer, if the XML-RPC response contains
-# a fault string. This exception can also used as a class, to
+# a fault string. This exception can also be used as a class, to
# generate a fault XML-RPC message.
#
# @param faultCode The XML-RPC fault code.
@@ -243,10 +238,7 @@ class Fault(Error):
self.faultCode = faultCode
self.faultString = faultString
def __repr__(self):
- return (
- "<Fault %s: %s>" %
- (self.faultCode, repr(self.faultString))
- )
+ return "<Fault %s: %r>" % (self.faultCode, self.faultString)
# --------------------------------------------------------------------
# Special values
@@ -302,7 +294,7 @@ class DateTime:
elif datetime and isinstance(other, datetime.datetime):
s = self.value
o = other.strftime("%Y%m%dT%H:%M:%S")
- elif isinstance(other, (str, unicode)):
+ elif isinstance(other, str):
s = self.value
o = other
elif hasattr(other, "timetuple"):
@@ -352,7 +344,7 @@ class DateTime:
return self.value
def __repr__(self):
- return "<DateTime %s at %x>" % (repr(self.value), id(self))
+ return "<DateTime %r at %x>" % (self.value, id(self))
def decode(self, data):
self.value = str(data).strip()
@@ -378,9 +370,6 @@ def _datetime_type(data):
#
# @param data An 8-bit string containing arbitrary data.
-import base64
-import io
-
class Binary:
"""Wrapper for binary data."""
@@ -514,9 +503,7 @@ class Marshaller:
f = self.dispatch[type(value)]
except KeyError:
# check if this object can be marshalled as a structure
- try:
- value.__dict__
- except:
+ if not hasattr(value, '__dict__'):
raise TypeError("cannot marshal %s objects" % type(value))
# check if this class is a sub-class of a basic type,
# because we don't know how to marshal these types
@@ -558,12 +545,6 @@ class Marshaller:
write("</double></value>\n")
dispatch[float] = dump_double
- def dump_string(self, value, write, escape=escape):
- write("<value><string>")
- write(escape(value))
- write("</string></value>\n")
- dispatch[bytes] = dump_string
-
def dump_unicode(self, value, write, escape=escape):
write("<value><string>")
write(escape(value))
@@ -1192,7 +1173,6 @@ class Transport:
auth, host = urllib.parse.splituser(host)
if auth:
- import base64
auth = urllib.parse.unquote_to_bytes(auth)
auth = base64.encodebytes(auth).decode("utf-8")
auth = "".join(auth.split()) # get rid of whitespace
diff --git a/Lib/xmlrpc/server.py b/Lib/xmlrpc/server.py
index ac252f1..72f3bfc 100644
--- a/Lib/xmlrpc/server.py
+++ b/Lib/xmlrpc/server.py
@@ -329,7 +329,6 @@ class SimpleXMLRPCDispatcher:
if method is None:
return ""
else:
- import pydoc
return pydoc.getdoc(method)
def system_multicall(self, call_list):
@@ -560,7 +559,7 @@ class SimpleXMLRPCServer(socketserver.TCPServer,
Simple XML-RPC server that allows functions and a single instance
to be installed to handle requests. The default implementation
attempts to dispatch XML-RPC calls to the functions or instance
- installed in the server. Override the _dispatch method inhereted
+ installed in the server. Override the _dispatch method inherited
from SimpleXMLRPCDispatcher to change this behavior.
"""
@@ -602,7 +601,7 @@ class MultiPathXMLRPCServer(SimpleXMLRPCServer):
encoding, bind_and_activate)
self.dispatchers = {}
self.allow_none = allow_none
- self.encoding = encoding
+ self.encoding = encoding or 'utf-8'
def add_dispatcher(self, path, dispatcher):
self.dispatchers[path] = dispatcher
@@ -620,9 +619,10 @@ class MultiPathXMLRPCServer(SimpleXMLRPCServer):
# (each dispatcher should have handled their own
# exceptions)
exc_type, exc_value = sys.exc_info()[:2]
- response = xmlrpclib.dumps(
- xmlrpclib.Fault(1, "%s:%s" % (exc_type, exc_value)),
+ response = dumps(
+ Fault(1, "%s:%s" % (exc_type, exc_value)),
encoding=self.encoding, allow_none=self.allow_none)
+ response = response.encode(self.encoding)
return response
class CGIXMLRPCRequestHandler(SimpleXMLRPCDispatcher):