[EuroPython] Exporting the registration data

M.-A. Lemburg mal@lemburg.com
Tue, 28 May 2002 18:02:12 +0200


M.-A. Lemburg wrote:
> Joachim Schmitz wrote:
> 
>> This is a bug in  xmlrpclib.py
>>
>> change _decode around line 105 of xmlrpclib.py like so:
>>
>> def _decode(data, encoding, is8bit=re.compile("[\x80-\xff]").search):
>>    # decode non-ascii string (if possible)
>>    if unicode and is8bit(data):
>>        try:
>>            data = unicode(data, encoding)
>>        except:
>>            pass
>>            #data = "error decoding"
>>    return data
>>
> 
> This would just be a gross hack :-)

Here's a different way of solving the problem without having
to change xmlrpclib (the change would cause you harm with other
applications !).

Add the following lines to the Getxmldata.py:

class BasicAuthTransport(xmlrpclib.Transport): #{{{
     ...

     def getparser(self):
         # get parser and unmarshaller
         target = MyUnmarshaller()
         return xmlrpclib.SlowParser(target), target

class MyUnmarshaller(xmlrpclib.Unmarshaller):

     def xml(self, encoding, standalone):
         self._encoding = 'latin-1'

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
______________________________________________________________________
Company & Consulting:                           http://www.egenix.com/
Python Software:                   http://www.egenix.com/files/python/
Meet us at EuroPython 2002:                 http://www.europython.org/