[XML-SIG] Python 1.5 support with PyXML 0.6.2/4Suite0.9.2

Alexandre Fayolle Alexandre.Fayolle@logilab.fr
Fri, 17 Nov 2000 10:51:25 +0100 (CET)

On Thu, 16 Nov 2000, Martin v. Loewis wrote:

> > I would like to have some clarification about the python 1.52 support in
> > PyXML 0.6.2 and 4Suite 0.9.2. 4Suite specifies it nees PyXML 0.6.2 to
> > run. Is it 6.2 for python 2.0 and 5.5.1 for python 1.52 ?
> PyXML supports both Python 1.5.2, and Python 2.0.
> > I could not find the xml.unicode package in pyxml 0.6.2...
> There isn't any such package. Why do you think it should be there?

Well, just 'cos it was there in PyXML and 4Suite seems to
heavily depend on it when running under python 1.5.2

in Printer.py, there are things like:

    #The following stanza courtesy Martin von Loewis
    import codecs # Python 1.5 only
    from types import UnicodeType
    def utf8_to_code(text, encoding):
        encoder = codecs.lookup(encoding)[0] # encode,decode,reader,writer
        if type(text) is not UnicodeType:
            text = unicode(text, "utf-8")
        return encoder(text)[0] # result,size
except ImportError:
    def utf8_to_code(text, encoding):
        encoding = string.upper(encoding)
        if encoding == 'UTF-8':
            return text
        from xml.unicode.iso8859 import wstring
        wstring.install_alias('ISO-8859-1', 'ISO_8859-1:1987')
        #Note: Pass through to wstrop.  This means we don't play nice and
        #Escape characters that are not in the target encoding.
        ws = wstring.from_utf8(text)
        text = ws.encode(encoding)
        #This version would skip all untranslatable chars: see wstrop.c
        #text = ws.encode(encoding, 1)
        return text

There is an error in the comment of line 3 of the above snippet
(codecs are only in python2.0), so Python 1.5 will actually execute the
except statement, and therefore an xml.unicode.iso8859 package seems to be

Alexandre Fayolle
Narval is the first software agent available as free software (GPL).
LOGILAB, Paris (France).