@@ -166,11 +166,13 @@ def _stringify(string):
166166
167167class Error (Exception ):
168168 """Base class for client errors."""
169- pass
169+ def __str__ (self ):
170+ return repr (self )
170171
171172class ProtocolError (Error ):
172173 """Indicates an HTTP protocol error."""
173174 def __init__ (self , url , errcode , errmsg , headers ):
175+ Error .__init__ (self )
174176 self .url = url
175177 self .errcode = errcode
176178 self .errmsg = errmsg
@@ -188,12 +190,13 @@ class ResponseError(Error):
188190class Fault (Error ):
189191 """Indicates an XML-RPC fault package."""
190192 def __init__ (self , faultCode , faultString , ** extra ):
193+ Error .__init__ (self )
191194 self .faultCode = faultCode
192195 self .faultString = faultString
193196 def __repr__ (self ):
194197 return (
195198 "<Fault %s: %s>" %
196- (repr ( self .faultCode ) , repr (self .faultString ))
199+ (self .faultCode , repr (self .faultString ))
197200 )
198201
199202# --------------------------------------------------------------------
@@ -399,8 +402,10 @@ def __init__(self, target):
399402 self .unknown_starttag = target .start
400403 self .handle_data = target .data
401404 self .unknown_endtag = target .end
402- xmllib .XMLParser .__init__ (self )
403-
405+ try :
406+ xmllib .XMLParser .__init__ (self , accept_utf8 = 1 )
407+ except TypeError :
408+ xmllib .XMLParser .__init__ (self ) # pre-2.0
404409
405410# --------------------------------------------------------------------
406411# XML-RPC marshalling and unmarshalling code
@@ -521,11 +526,11 @@ def dump_instance(self, value):
521526
522527class Unmarshaller :
523528 """Unmarshal an XML-RPC response, based on incoming XML event
524- messages (start, data, end). Call close to get the resulting
529+ messages (start, data, end). Call close() to get the resulting
525530 data structure.
526531
527- Note that this reader is fairly tolerant, and gladly accepts
528- bogus XML-RPC data without complaining (but not bogus XML).
532+ Note that this reader is fairly tolerant, and gladly accepts bogus
533+ XML-RPC data without complaining (but not bogus XML).
529534 """
530535
531536 # and again, if you don't understand what's going on in here,
@@ -688,8 +693,8 @@ def end_methodName(self, data, join=string.join):
688693def getparser ():
689694 """getparser() -> parser, unmarshaller
690695
691- Create an instance of the fastest available parser, and attach
692- it to an unmarshalling object. Return both objects.
696+ Create an instance of the fastest available parser, and attach it
697+ to an unmarshalling object. Return both objects.
693698 """
694699 if FastParser and FastUnmarshaller :
695700 target = FastUnmarshaller (True , False , binary , datetime )
@@ -712,8 +717,8 @@ def dumps(params, methodname=None, methodresponse=None, encoding=None):
712717 Convert an argument tuple or a Fault instance to an XML-RPC
713718 request (or response, if the methodresponse option is used).
714719
715- In addition to the data object, the following options can be
716- given as keyword arguments:
720+ In addition to the data object, the following options can be given
721+ as keyword arguments:
717722
718723 methodname: the method name for a methodCall packet
719724
@@ -725,7 +730,7 @@ def dumps(params, methodname=None, methodresponse=None, encoding=None):
725730
726731 All 8-bit strings in the data structure are assumed to use the
727732 packet encoding. Unicode strings are automatically converted,
728- as necessary.
733+ where necessary.
729734 """
730735
731736 assert isinstance (params , TupleType ) or isinstance (params , Fault ),\
0 commit comments