Getting better traceback info on exec and execfile - introspection?

R. Bernstein rocky at
Mon Jan 16 10:15:27 CET 2006

Fernando Perez < at> 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

    # 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

More information about the Python-list mailing list