[XML-SIG] Better pyexpat backtraces
Martin v. Loewis
martin@loewis.home.cs.tu-berlin.de
Sat, 23 Dec 2000 23:56:29 +0100
Since a number of people have run into the trap of thinking that Parse
is called with a bad argument number, I just checked-in a patch to
pyexpat that adds an artificial frame object on the stack. With that,
if you pass a DocumentHandler in place of a ContentHandler, you now
get a back-trace that reads
Traceback (most recent call last):
File "a.py", line 48, in ?
parser.parse( comic_xml )
File "/usr/local/lib/python2.0/site-packages/_xmlplus/sax/expatreader.py", line 43, in parse
xmlreader.IncrementalParser.parse(self, source)
File "/usr/local/lib/python2.0/site-packages/_xmlplus/sax/xmlreader.py", line 120, in parse
self.feed(buffer)
File "/usr/local/lib/python2.0/site-packages/_xmlplus/sax/expatreader.py", line 87, in feed
self._parser.Parse(data, isFinal)
File "pyexpat.c", line 370, in CharacterData
TypeError: not enough arguments to characters(); expected 4, got 2
Normally, you would not get a stack frame that points to pyexpat.c;
please let me know what you think.
The "to characters()" part is not my doing; that is a Python 2.1
feature.
Regards,
Martin