[issue35857] Stacktrace shows lines from updated file on disk, not code actually running

2019-01-30 Thread Steven D'Aprano
Steven D'Aprano added the comment: > For information - all taken from docs and Lib/*.py I'm sorry Jonathon, I don't see how they are relevant or interesting to the topic in hand other than "they're used to print stack traces". Okay, they're used to print stack traces. And...? Can you

[issue35857] Stacktrace shows lines from updated file on disk, not code actually running

2019-01-30 Thread Jonathan Fine
Jonathan Fine added the comment: For information - all taken from docs and Lib/*.py https://docs.python.org/3.7/library/traceback.html traceback -- Print or retrieve a stack traceback Source code: Lib/traceback.py === This module provides a standard interface to extract, format and print stack

[issue35857] Stacktrace shows lines from updated file on disk, not code actually running

2019-01-30 Thread Stefan Behnel
Stefan Behnel added the comment: I think the REPL could, when it formats a stack trace for printing, check every referenced source file if it's newer than its compiled .pyc (bytecode) file, and insert a warning into the stack trace if that is the case. I don't see any use in doing this for

[issue35857] Stacktrace shows lines from updated file on disk, not code actually running

2019-01-30 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Looking more into the issue8087 there is issue31300 and issue23594 that are linked as duplicates with issue31300 very similar to this report. Maybe close this to continue discussion on issue8087? -- ___

[issue35857] Stacktrace shows lines from updated file on disk, not code actually running

2019-01-30 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: See also issue8087 that has a similar case with interactive shell where the imported module was changed on disk. It has some discussion along similar lines with some more possible cases msg145291. -- nosy: +xtreak

[issue35857] Stacktrace shows lines from updated file on disk, not code actually running

2019-01-30 Thread Jonathan Fine
Jonathan Fine added the comment: The problem, as I understand it, is a mismatch between the code object being executed and the file on disk referred to by the code object. When a module is reloaded it is first recompiled, if the .py file is newer than the .pyc file. (I've tested this at a

[issue35857] Stacktrace shows lines from updated file on disk, not code actually running

2019-01-30 Thread Steven D'Aprano
Steven D'Aprano added the comment: There may be something we can do to improve the error reporting and make it less perplexing: https://mail.python.org/pipermail/python-ideas/2019-January/055041.html -- ___ Python tracker

[issue35857] Stacktrace shows lines from updated file on disk, not code actually running

2019-01-30 Thread Steve Pryde
Steve Pryde added the comment: > How is Python supposed to do that without making a copy of every module and > script it runs just in case it gets modified? Aha, I suspected this might be the reason. Feel free to close this issue if there's nothing else to be said here. Python certainly

[issue35857] Stacktrace shows lines from updated file on disk, not code actually running

2019-01-30 Thread Steven D'Aprano
Steven D'Aprano added the comment: > It should instead show the lines from the file as it was when the code was > executed. How is Python supposed to do that without making a copy of every module and script it runs just in case it gets modified? (That's not a rhetorical question -- if you

[issue35857] Stacktrace shows lines from updated file on disk, not code actually running

2019-01-29 Thread Steve Pryde
New submission from Steve Pryde : When python prints or returns a stacktrace, it displays the appropriate line from the *current file on disk*, which may have changed since the program was run. It should instead show the lines from the file as it was when the code was executed. Steps to