[Python-bugs-list] [ python-Bugs-534864 ] profiling with xml parsing asserts
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 02 Jul 2002 00:05:42 -0700
Bugs item #534864, was opened at 2002-03-25 22:15
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=534864&group_id=5470
Category: Python Library
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Aron K. Insinga (ainsinga)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: profiling with xml parsing asserts
Initial Comment:
I'm getting a 'bad call' assertion error when using the
profiler when parsing XML. (It works ok without the
profiler, and if I don't call SAXparser.parse it
doesn't happen.)
Python 2.2 (#1, Dec 23 2001, 09:30:32)
[GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-98)] on
linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> import t4crash
start document
end document
>>> import profile
>>> t4crash.test()
start document
end document
>>> profile.run('t4crash.test()')
start document
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.2/profile.py", line 71, in run
prof = prof.run(statement)
File "/usr/lib/python2.2/profile.py", line 404, in
run
return self.runctx(cmd, dict, dict)
File "/usr/lib/python2.2/profile.py", line 410, in
runctx
exec cmd in globals, locals
File "<string>", line 1, in ?
File "t4crash.py", line 46, in test
main(files)
File "t4crash.py", line 39, in main
SAXparser.parse(fileName)
File
"/var/tmp/python2-2.2-root/usr/lib/python2.2/xml/sax/expatreader.py",
line 53, in parse
File
"/var/tmp/python2-2.2-root/usr/lib/python2.2/xml/sax/xmlreader.py",
line
123, in parse File
"/var/tmp/python2-2.2-root/usr/lib/python2.2/xml/sax/expatreader.py",
line 106,
in feed
File
"/var/tmp/python2-2.2-root/usr/lib/python2.2/xml/sax/expatreader.py",
line 179, in start_element
File "/usr/lib/python2.2/profile.py", line 214, in
trace_dispatch_i
if self.dispatch[event](self, frame,t):
File "/usr/lib/python2.2/profile.py", line 260, in
trace_dispatch_call
assert rframe.f_back is frame.f_back, ("Bad call",
rfn,
AssertionError: ('Bad call',
('/var/tmp/python2-2.2-root/usr/lib/python2.2/xml/sax/expatreader.py',
95,
'feed'), <frame object at 0x81d5454>, <frame object at
0x81c82e4>, <frame object
at 0x81d50b4>, <frame object at 0x81d5284>)
>>>
[ainsinga@ainsinga index_xml]$ cat t4crash.py
#!/usr/bin/env python2
# t4crash.py by Aron K. Insinga (aron.insinga@av.com)
25-Mar-2002
import xml.sax
import sys
import string
import re
class ContentHandler(xml.sax.ContentHandler):
""" Handle callbacks from the SAX XML parser. """
def __init__(selfy):
pass
def setDocumentLocator(self, locator):
pass
def startDocument(self):
print 'start document'
def endDocument(self):
print 'end document'
def startElement(self, name, attrs):
pass
def endElement(self, name):
pass
def main(files):
SAXparser = xml.sax.make_parser()
chand = ContentHandler()
SAXparser.setContentHandler(chand)
try:
for fileName in files:
SAXparser.parse(fileName)
except xml.sax.SAXParseException:
sys.stderr.write("%s; processing aborted\n" %
(xml.sax.SAXParseException))
sys.exit(1)
def test():
files = ['doc0.xml']
main(files)
test()
[ainsinga@ainsinga index_xml]$ cat doc0.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<html>
<head>
<title>Gettysburg Address</title>
</head>
<body>
<p>
Four score and seven years ago...<br/>
</p>
</body>
<info>
<author>
<lastname>Lincoln</lastname><firstname>Abraham</firstname>
</author>
<date>
<month>11</month><day>19</day><year>1863</year>
</date>
<editor /><!-- editor name="aki"/ -->
<editor/>
</info>
</html>
[ainsinga@ainsinga index_xml]$ which python
/usr/bin/python
[ainsinga@ainsinga index_xml]$ set | grep PATH
LD_LIBRARY_PATH=/home/ainsinga/adabas/lib:/home/ainsinga/adabas/lib:/home/ainsinga/adabas/lib:/home/ainsinga/adabas/lib:/home/ainsinga/adabas/lib:
PATH=$'/home/ainsinga/adabas/bin:/home/ainsinga/adabas/pgm:.:/home/ainsinga/adabas/bin:/home/ainsinga/adabas/pgm:.:/home/ainsinga/adabas/bin:/home/ainsinga/adabas/pgm:.:/home/ainsinga/adabas/bin:/home/ainsinga/adabas/pgm:.:.:/home/ainsinga/bin:/home/ainsinga/adabas/bin:/home/ainsinga/adabas/pgm:.:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:~/staroffice6.0:/home/ainsinga/mozilla:~/staroffice6.0:/home/ainsinga/mozilla:~/staroffice6.0:/home/ainsinga/mozilla:~/staroffice6.0:/home/ainsinga/mozilla:~/
staroffice6.0:/home/ainsinga/mozilla'
[ainsinga@ainsinga index_xml]$ set | grep -i py
[ainsinga@ainsinga index_xml]$uname -a
Linux ainsinga 2.4.7-10 #1 Thu Sep 6 17:27:27 EDT 2001
i686 unknown
[ainsinga@ainsinga index_xml]$
----------------------------------------------------------------------
>Comment By: Martin v. Löwis (loewis)
Date: 2002-07-02 09:05
Message:
Logged In: YES
user_id=21627
Attached is a patch that fixes the problem.
----------------------------------------------------------------------
Comment By: Andrew P. Lentvorski, Jr. (andrewl)
Date: 2002-07-02 02:13
Message:
Logged In: YES
user_id=28733
The xmltest.py program follows since I appear to be too
stupid to figure out how to attach a file to a bug report on
SourceForge.
-a
#!/usr/bin/env python
import xml.sax
testxml = \
"""
<html />
"""
class ContentHandler(xml.sax.ContentHandler):
""" Handle callbacks from the SAX XML parser. """
def __init__(self):
pass
def startElement(self, name, attrs):
print "start element"
def endElement(self, name):
print "end element"
def main():
chand = ContentHandler()
xml.sax.parseString(testxml, chand)
if __name__ == "__main__":
main()
----------------------------------------------------------------------
Comment By: Andrew P. Lentvorski, Jr. (andrewl)
Date: 2002-07-02 02:01
Message:
Logged In: YES
user_id=28733
Here is a session log for a much more self-contained
regression file (xmltest.py):
andrewl@taz:andrewl$ python
Python 2.2.1 (#1, May 27 2002, 16:42:22)
[GCC 2.95.3 20010315 (release) [FreeBSD]] on freebsd4
Type "help", "copyright", "credits" or "license" for more
information.
>>> import profile
>>> import xmltest
>>> profile.run('xmltest.main()')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/local/lib/python2.2/profile.py", line 71, in
run
prof = prof.run(statement)
File "/usr/local/lib/python2.2/profile.py", line 404, in
run
return self.runctx(cmd, dict, dict)
File "/usr/local/lib/python2.2/profile.py", line 410, in
runctx
exec cmd in globals, locals
File "<string>", line 1, in ?
File "xmltest.py", line 24, in main
xml.sax.parseString(testxml, chand)
File "/usr/local/lib/python2.2/xml/sax/__init__.py", line
49, in parseString
parser.parse(inpsrc)
File "/usr/local/lib/python2.2/xml/sax/expatreader.py",
line 90, in parse
xmlreader.IncrementalParser.parse(self, source)
File "/usr/local/lib/python2.2/xml/sax/xmlreader.py", line
123, in parse
self.feed(buffer)
File "/usr/local/lib/python2.2/xml/sax/expatreader.py",
line 143, in feed
self._parser.Parse(data, isFinal)
File "/usr/local/lib/python2.2/xml/sax/expatreader.py",
line 216, in start_element
def start_element(self, name, attrs):
File "/usr/local/lib/python2.2/profile.py", line 214, in
trace_dispatch_i
if self.dispatch[event](self, frame,t):
File "/usr/local/lib/python2.2/profile.py", line 260, in
trace_dispatch_call
assert rframe.f_back is frame.f_back, ("Bad call", rfn,
AssertionError: ('Bad call',
('/usr/local/lib/python2.2/xml/sax/expatreader.py', 132,
'feed'), <frame object at 0x81a880c>, <frame object at
0x81a840c>, <frame object at 0x81bb60c>, <frame object at
0x81a8a0c>)
----------------------------------------------------------------------
Comment By: Andrew P. Lentvorski, Jr. (andrewl)
Date: 2002-07-02 00:57
Message:
Logged In: YES
user_id=28733
There is another filing on this problem at:
http://mail.python.org/pipermail/xml-sig/2002-April/007632.html
Also, I reproduced this on another FreeBSD box today as
well.
andrewl@taz:andrewl$ python
Python 2.2.1 (#1, May 27 2002, 16:42:22)
[GCC 2.95.3 20010315 (release) [FreeBSD]] on freebsd4
-a
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2002-07-01 17:55
Message:
Logged In: YES
user_id=31435
I reproduced this with current CVS Python on Windows;
see attached traceback.txt, which shows a screen dump of
the offending <wink> interactive session.
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2002-07-01 07:55
Message:
Logged In: YES
user_id=21627
I can't reproduce it with the Python 2.2 that ships with
SuSE 8.0, either.
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2002-03-27 13:30
Message:
Logged In: YES
user_id=21627
I can't reproduce the crash, with 2.3a0.
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2002-03-25 23:27
Message:
Logged In: YES
user_id=31435
Assigned to Fred.
----------------------------------------------------------------------
Comment By: Aron K. Insinga (ainsinga)
Date: 2002-03-25 22:19
Message:
Logged In: YES
user_id=496408
attached is the sample program (which ought to have
indenting preserved!)
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=534864&group_id=5470