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 +--------- Misc/NEWS | 3 +++ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py index bd59f32..97d5aac 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)) diff --git a/Misc/NEWS b/Misc/NEWS index 80c435a..70572b4 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -63,6 +63,9 @@ Core and Builtins Library ------- +- Issue #13293: Better error message when trying to marshal bytes using + xmlrpc.client. + - Issue #13291: NameError in xmlrpc package. - Issue #13258: Use callable() built-in in the standard library. -- cgit v0.12