Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 93dfee1

Browse files
committed
Issue #13293: Better error message when trying to marshal bytes using xmlrpc.client.
1 parent c4fec93 commit 93dfee1

2 files changed

Lines changed: 4 additions & 9 deletions

File tree

Lib/xmlrpc/client.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,7 @@ def __dump(self, value, write):
503503
f = self.dispatch[type(value)]
504504
except KeyError:
505505
# check if this object can be marshalled as a structure
506-
try:
507-
value.__dict__
508-
except:
506+
if not hasattr(value, '__dict__'):
509507
raise TypeError("cannot marshal %s objects" % type(value))
510508
# check if this class is a sub-class of a basic type,
511509
# because we don't know how to marshal these types
@@ -553,12 +551,6 @@ def dump_double(self, value, write):
553551
write("</double></value>\n")
554552
dispatch[float] = dump_double
555553

556-
def dump_string(self, value, write, escape=escape):
557-
write("<value><string>")
558-
write(escape(value))
559-
write("</string></value>\n")
560-
dispatch[bytes] = dump_string
561-
562554
def dump_unicode(self, value, write, escape=escape):
563555
write("<value><string>")
564556
write(escape(value))

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ Core and Builtins
6363
Library
6464
-------
6565

66+
- Issue #13293: Better error message when trying to marshal bytes using
67+
xmlrpc.client.
68+
6669
- Issue #13291: NameError in xmlrpc package.
6770

6871
- Issue #13258: Use callable() built-in in the standard library.

0 commit comments

Comments
 (0)