On 3/17/07, Ewan Mellor <[EMAIL PROTECTED]> wrote: > I have a problem being reported (by Xen users) where inspect.stack() is > throwing IndexError. I think that this is a bug in inspect.py -- findsource > generally throws IOError when it can't find a particular source file, but in > the case where it finds a source file, but that file is shorter than expected, > then findsource throws IndexError, and this is propagated all the way out of > inspect.stack(). > > I'm not sure why inspect.py is finding source files that don't match the code > being executed -- it seems to be dependent upon the install environment, > because it's not affecting most people. That said, I think that it's > reasonable to cope with a too-short source file in the same way as we cope > with missing source files -- by throwing IOError from findsource and handling > that exception later.
FYI: this has been reported at least once before: see bug #1628987 (http://python.org/sf/1628987). The problem (in the bug report, at least) is that the source file changes between compilation and when findsource() is called, and findsource() picks up the modified version. Collin Winter _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com