For Python 3.0b2 on Windows I don't see any test_xml_sax.py file in
Python30\Lib\test for b2. Do unit tests exist?

While trying to bring up Leo, I found what looks like a bug that will cause
any byte stream to loop when calling xml.sax.parser.parse.  My quick fix was
to change:

    while buffer != "":

to:

    while buffer != "" and buffer != b"":

at line 123 of xmlreader.py

Here is the entire function:

def parse(self, source):
        from . import saxutils
        source = saxutils.prepare_input_source(source)

        self.prepareParser(source)
        file = source.getByteStream()
        buffer = file.read(self._bufsize)
        ### while buffer != "":
        while buffer != "" and buffer != b"": ### EKR
            self.feed(buffer)
            buffer = file.read(self._bufsize)
        self.close()

For reference, here is the code in Leo that was hanging::

        parser = xml.sax.make_parser()
        parser.setFeature(xml.sax.handler.feature_external_ges,1)
            # Include external general entities, esp. xml-stylesheet lines.
        handler = saxContentHandler(c,inputFileName,silent,inClipboard)
        parser.setContentHandler(handler)
        ### theFile must be a byte stream?
        ### hangs in a loop in xmlreader.py near line 124.
        ### I hacked the code to fix it.
        parser.parse(theFile) # expat does not support parseString

In this case theFile is simply the result of open(filename,'r') Iirc,
attempting to speed up the parsing using various io.streams slowed things
down dramatically.  Anyway, the code above works in Python 2.5.

Python26 -3 reports no errors in Leo, although several errors are reported
in tkinter and Pmw 1.3.

I'm concerned about missing unit tests for the sax module. The new io module
has the potential to break lots of code in subtle ways, as shown above.

I can't tell you more about sax until I sidestep Pmw and tkinter libs that
aren't importing...Hopefully I'll get a curses gui working soon for Leo :-)

I'm highly motivated to get tkinter, Pmw and sax working...Let me know if I
can help.  Is anyone else working on these libs?

Edward
--------------------------------------------------------------------
Edward K. Ream email: [EMAIL PROTECTED]
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to