[XML-SIG] Expat and the Python Profiler

Alexandre Alexandre.Fayolle@logilab.fr
Mon, 19 Aug 2002 10:20:59 +0200


On Fri, Aug 16, 2002 at 09:24:56PM +0200, Martin v. Loewis wrote:
> Alexandre <Alexandre.Fayolle@logilab.fr> writes:
> 
> > The Frame created by pyexpat is unknown to the profiler when the
> > callback function is executed. 
> > 
> > This looks like a recent change in pyexpat  (to avoid dumping core when an 
> > exception is raised in a callback maybe?), but not being able to profile
> > code is really annoying. 
> 
> My question: What version? There was a relatively recent (read:
> January 2001) change to pyexpat.c to add that frame, and a even more
> recent change (read: August 2002) to fix the problem with tracing.

as of PyXML 0.8 or current CVS, de)ênding on the machine I tested on.
Sorry for not providing the information. 

> 
> > So the first question is: is this a feature of expat, or a bug in the
> > profiler? Do you have any suggestion?
> 
> It's a feature in expat to add this frame, so that a traceback in the
> callback won't show feed() as the topmost function.
> 
> It's a bug in pyexpat.c (as shipped in PyXML 0.8) that this broke
> tracing; it's a fix in 2.72 of Python CVS that corrects this bug.

OK. 


> If you need an urgent fix for your code base, feel free to backport
> this fix to whereever you need it; I'm leaving for two weeks, so I
> don't have the time to do this myself.

See you soon then. 

I've extracted the patch to apply it on pyxml. The problem I have is that
it doesn't seem to be compatible with python < 2.2 (it uses the PyTrace_CALL 
constant which is not defined in python 2.1). 

Is making the patch available only to users of python2.2 an acceptable
solution? I'll try to do that and I'll post it on the SF patch manager
for review. 

 
Alexandre Fayolle
-- 
LOGILAB, Paris (France).
http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org
Narval, the first software agent available as free software (GPL).