summaryrefslogtreecommitdiffstats
path: root/Lib/xmlrpclib.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-08-27 22:27:41 (GMT)
committerGuido van Rossum <guido@python.org>2007-08-27 22:27:41 (GMT)
commit54a40cb81f2bbc7ec263196eaa4ce05151ab93ce (patch)
treeca2c376286d42ae43d737d7cd385da5ffc4dd02e /Lib/xmlrpclib.py
parent98b349f8e6efc5c1994e506c02a755f311d49f03 (diff)
downloadcpython-54a40cb81f2bbc7ec263196eaa4ce05151ab93ce.zip
cpython-54a40cb81f2bbc7ec263196eaa4ce05151ab93ce.tar.gz
cpython-54a40cb81f2bbc7ec263196eaa4ce05151ab93ce.tar.bz2
Force test_xmlrpc to pass. I'm not happy with how I did this, but I don't
see a better way; the 'Binary' class is poorly specified so it's unclear what behavior is relied upon.
Diffstat (limited to 'Lib/xmlrpclib.py')
-rw-r--r--Lib/xmlrpclib.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/Lib/xmlrpclib.py b/Lib/xmlrpclib.py
index abd1a07..586dc4c 100644
--- a/Lib/xmlrpclib.py
+++ b/Lib/xmlrpclib.py
@@ -364,6 +364,13 @@ class Binary:
"""Wrapper for binary data."""
def __init__(self, data=None):
+ if data is None:
+ data = b""
+ else:
+ if not isinstance(data, bytes):
+ raise TypeError("expected bytes, not %s" %
+ data.__class__.__name__)
+ data = bytes(data) # Make a copy of the bytes!
self.data = data
##
@@ -372,7 +379,7 @@ class Binary:
# @return Buffer contents, as an 8-bit string.
def __str__(self):
- return self.data or ""
+ return str(self.data, "latin-1") # XXX encoding?!
def __eq__(self, other):
if isinstance(other, Binary):
@@ -385,7 +392,7 @@ class Binary:
return self.data != other
def decode(self, data):
- self.data = str8(base64.decodestring(data))
+ self.data = base64.decodestring(data)
def encode(self, out):
out.write("<value><base64>\n")
@@ -827,7 +834,7 @@ class Unmarshaller:
def end_base64(self, data):
value = Binary()
- value.decode(data)
+ value.decode(data.encode("ascii"))
self.append(value)
self._value = 0
dispatch["base64"] = end_base64