[XML-SIG] Specializing DOM exceptions

Paul Prescod paul@prescod.net
Thu, 07 Dec 2000 06:07:42 -0500


"Martin v. Loewis" wrote:
> 
>...
> 
> Nobody would expect that splitText could possibly raise
> IndexError. Nobody would guess that it could raise IndexSizeErr,
> either - but at least you'd have the DOM documentation to tell you.

The DOM documentation does not mention a Python IndexSizeErr exception.
That's part of the Python binding so you can only find out about it in
the Python documentation.

> (*) In DOM, childNodes does not have a []-operator; only a method
> item(). Interestingly enough, that method is specified to return null
> in case of an out-of-range index, not to raise INDEX_SIZE_ERR.

That's part of the Python binding also:

>>> from xml.dom.minidom import parse
>>> d = parse("c:\\temp\\test.xml")
<xml.dom.minidom.Document instance at 0083C15C>
>>> d.childNodes[0]
<DOM Element: abc at 8452044>

I don't think returning null would be very Pythonic.

 Paul Prescod