Getting better traceback info on exec and execfile - introspection?
R. Bernstein
rocky at panix.com
Mon Jan 16 04:15:27 EST 2006
Fernando Perez <fperez.net at gmail.com> writes:
> So any regexp-matching based approach here is likely to be fairly brittle,
> unless you restrict your tool to the standard python interpreter, and you
> get some guarantee that it will always tag interactive code with
> '<string>'.
Meant to mention for what it's worth. Looks like I'm not the first to use the
filename == '<string>' test. I note this in the stock pdb.py:
# To be overridden in derived debuggers
def defaultFile(self):
"""Produce a reasonable default."""
filename = self.curframe.f_code.co_filename
if filename == '<string>' and self.mainpyfile:
filename = self.mainpyfile
return filename
I'm not sure under what conditions this equality test normally occurs
though.
More information about the Python-list
mailing list