From 3fa29f7cd77970df2d85db3e7565cf0ad2548883 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Sun, 30 Oct 2011 20:18:50 +0100 Subject: Closes #13291: NameError in xmlrpc package. --- Lib/xmlrpc/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Lib/xmlrpc/client.py') diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py index 19d4d6986f..9312344b47 100644 --- a/Lib/xmlrpc/client.py +++ b/Lib/xmlrpc/client.py @@ -302,7 +302,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"): -- cgit v1.2.1 From c4fec937dcb70175fb0a0e772563a35ebba2d1c6 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Sun, 30 Oct 2011 20:19:32 +0100 Subject: Cleanup xmlrpc: remove obsolete comments, unused imports. Add test for bytes marshalling. --- Lib/xmlrpc/client.py | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'Lib/xmlrpc/client.py') diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py index 9312344b47..bd59f326fb 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 ( - "" % - (self.faultCode, repr(self.faultString)) - ) + return "" % (self.faultCode, self.faultString) # -------------------------------------------------------------------- # Special values @@ -352,7 +344,7 @@ class DateTime: return self.value def __repr__(self): - return "" % (repr(self.value), id(self)) + return "" % (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.""" @@ -1198,7 +1187,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 -- cgit v1.2.1 From 93dfee1dfc0bf572d4d9579fd455a72c0c81f148 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Sun, 30 Oct 2011 20:22:25 +0100 Subject: Issue #13293: Better error message when trying to marshal bytes using xmlrpc.client. --- Lib/xmlrpc/client.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'Lib/xmlrpc/client.py') diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py index bd59f326fb..97d5aac53d 100644 --- a/Lib/xmlrpc/client.py +++ b/Lib/xmlrpc/client.py @@ -503,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 @@ -553,12 +551,6 @@ class Marshaller: write("\n") dispatch[float] = dump_double - def dump_string(self, value, write, escape=escape): - write("") - write(escape(value)) - write("\n") - dispatch[bytes] = dump_string - def dump_unicode(self, value, write, escape=escape): write("") write(escape(value)) -- cgit v1.2.1