[Python-ideas] Stack traces ought to flag when a module has been changed on disk
boxed at killingar.net
Wed Jan 30 08:24:13 EST 2019
I've been bitten by this and it always costs me several minutes of confusion.
> On 30 Jan 2019, at 11:17, Steven D'Aprano <steve at pearwood.info> wrote:
> This thought is motivated by this bug report:
> If you import a module, then edit the .py file that goes with it, and
> then an exception occurs, the stack trace can show the wrong line.
> It doesn't happen very often, but when it does happen, it can be very
> perplexing. Here's a proposal:
> When a stack trace is printed, before printing each line, the
> interpreter checks whether the file's modification time is later than
> the time recorded in the .pyc file. If the times are different, the
> stack trace can flag the line and print an addition line stating that
> the file may have changed and the stack trace may not be accurate.
> Something like this perhaps?
> Traceback (most recent call last):
> File "spam.py", line 99, in <spam>
> File "eggs.py", line 123, in <eggs>
> ? for obj in sequence:
> File "cheese.py", line 456, in <cheese>
> n = len(x)
> *** one or more files may have changed
> *** lines starting with ? may be inaccurate
> TypeError: object of type 'NoneType' has no len()
> I don't think performance will matter. Generating stack traces are
> rarely performance critical, so I don't think that a few extra file
> system checks will make any meaningful difference.
> Python-ideas mailing list
> Python-ideas at python.org
> Code of Conduct: http://python.org/psf/codeofconduct/
More information about the Python-ideas