[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 reproduce:
1. Save the following code to a file and run it in a terminal.

import time 

time.sleep(600)

2. While it is running, insert a line before "time.sleep(600)", type some 
random characters, and save the file. The "time.sleep" should now be on line 4, 
and some random characters on line 3.

3. Now go back to the terminal and press Ctrl+C (to generate a stacktrace).


Expected output:

^CTraceback (most recent call last):
  File "py1.py", line 3, in 
time.sleep(600)
KeyboardInterrupt


Actual output:

^CTraceback (most recent call last):
  File "py1.py", line 3, in 
some random characters
KeyboardInterrupt

--
components: Interpreter Core
messages: 334544
nosy: Steve Pryde
priority: normal
severity: normal
status: open
title: Stacktrace shows lines from updated file on disk, not code actually 
running
type: behavior
versions: Python 3.7

___
Python tracker 
<https://bugs.python.org/issue35857>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 only executes the code as it was at the time of initial 
execution, or rather it executes the generated bytecode. I gather therefore 
that python has enough info to display the files and line numbers but not their 
contents (which must be loaded fresh from disk).

As mentioned, if this is the case, I'm happy for this to be closed. Cheers.

--

___
Python tracker 
<https://bugs.python.org/issue35857>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com