[Python-bugs-list] [ python-Bugs-534864 ] profiling with xml parsing asserts
noreply@sourceforge.net
noreply@sourceforge.net
Sun, 30 Jun 2002 22:55:52 -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-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