[Doc-SIG] Error in pyexpat docs
Sun, 29 Oct 2000 12:16:53 -0700
An excerpt from the Python 2.0 docs for pyexpat:
Parse XML data reading from the object file. file only needs to provide
the read(nbytes) method, returning the empty string when
there's no more data.
The following attributes contain values relating to the most recent error
encountered by an xmlparser object, and will only have correct
values once a call to Parse() or ParseFile() has raised a
Byte index at which an error occurred.
The wrong, "xml.parsers.expat" is the first indicator that there might be a
problem, yet I took the docs at their word and wrapped the call to ParseFile
in a blanket try/except, only to find that no exception of any sort is ever
raised by ParseFile.
It turns out that ParseFile actually returns 0 on error, returning 1 otherwise.
The first matter is that the code and the docs need to be reconciled.
However, I would _much_ rather prefer that things were as in the docs. I
think ParseFile should raise an exception rather than return an error flag.
Interestingly enough, this is the same argument I had with a colleague just
Uche Ogbuji Principal Consultant
email@example.com +1 303 583 9900 x 101
Fourthought, Inc. http://Fourthought.com
4735 East Walnut St, Ste. C, Boulder, CO 80301-2537, USA
Software-engineering, knowledge-management, XML, CORBA, Linux, Python