classification
Title: xml.sax.ParseException weirdness in python 2.5b1
Type: Stage:
Components: XML Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: fdrake, marienz, nnorwitz, zseil
Priority: critical Keywords:

Created on 2006-06-27 21:06 by marienz, last changed 2006-07-29 17:04 by fdrake. This issue is now closed.

Files
File name Uploaded Description Edit
sax-exceptions-test-case.diff fdrake, 2006-07-27 02:01 test case
Messages (7)
msg28945 - (view) Author: Marien Zwart (marienz) Date: 2006-06-27 21:06
There is something weird going on with xml.sax
exceptions, probably related to the xml/xmlcore shuffle:

from xml.sax import make_parser, SAXParseException
from StringIO import StringIO

parser = make_parser()

try:
    parser.parse(StringIO('invalid'))
except SAXParseException:
    print 'caught it!'

On python 2.4.3 this prints "caught it!". On python
2.5b1 the exception is not caught, because it is a
different  exception: an
xmlcore.sax._exceptions.SAXParseException. Printing the
SAXParseException imported from xml.sax gives "<class
'xml.sax._exceptions.SAXParseException'>".

Stumbled on this running the logilab-common (see
logilab.org) tests with python 2.5b1, but it seems
likely other code will be affected.
msg28946 - (view) Author: Ziga Seilnacht (zseil) * (Python committer) Date: 2006-07-10 07:37
Logged In: YES 
user_id=1326842

This bug is simmilar to http://python.org/sf/1511497.
It is caused by absolute imports in xmlcore.sax.expatreader.
Patch #1519796 ( http://python.org/sf/1519796 )
should fix it.
msg28947 - (view) Author: Fred L. Drake, Jr. (fdrake) (Python committer) Date: 2006-07-27 02:01
Logged In: YES 
user_id=3066

Patch #1519796 does not do anything for this, based on the
current trunk.  I've attached a diff containing a test case.
msg28948 - (view) Author: Fred L. Drake, Jr. (fdrake) (Python committer) Date: 2006-07-27 02:36
Logged In: YES 
user_id=3066

The patch attached contains the wrong bug number, but it
really is for this issue.
msg28949 - (view) Author: Fred L. Drake, Jr. (fdrake) (Python committer) Date: 2006-07-27 03:03
Logged In: YES 
user_id=3066

I've managed to come up with a patch that solves this
specific issue, but it really deals with the symptom and not
the real problems.

While I think the "xmlcore" package was the right idea, I'm
not convinced it can be correctly implemented without
enormous effort at this time.  Given the release schedule,
it doesn't make sense to jump through those hoops.  The
previous hackery that made allowed the PyXML distribution to
"replace" the standard library version of the "xml" package
worked only because there was only one public name for
whichever was being used.  Moving to the "xmlcore" package
proved to be more than that hack could support.

I think the right thing to do for Python 2.5 is to revert
the changes that added the "xmlcore" package.  Further
investigation into a better approach can be made for Python 2.6.
msg28950 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2006-07-27 03:31
Logged In: YES 
user_id=33168

I think Martin is of the same opinion.  This needs to be
resolved soon.
msg28951 - (view) Author: Fred L. Drake, Jr. (fdrake) (Python committer) Date: 2006-07-29 17:04
Logged In: YES 
user_id=3066

The xmlcore package has been reverted as of revision 50941.

This problem report no longer applies, but a test has been
added as part of the removal of the xmlcore package to
ensure this does not re-surface.
History
Date User Action Args
2006-06-27 21:06:49marienzcreate