This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Traceback: Exception Shows Code that's On-Disk (Not in memory)
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Guy, r.david.murray
Priority: normal Keywords:

Created on 2010-07-27 04:32 by Guy, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (4)
msg111685 - (view) Author: Guy (Guy) Date: 2010-07-27 04:32
When an exception is raised and Python's showing a traceback, the lines of the Python scripts are that of those on-disk, not in memory.

For example, if I run a Python script which raises an exception, but I edit the line the exception occurs on and save the script in the same location, the new line (The one that's not interpreted), will be shown in the traceback.
msg111752 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-07-28 00:39
Yes, this is the way it works.  There is no copy of the lines kept in memory, the only lines that can be displayed in the traceback are the ones currently on disk.

Although your speaking about a "script" is a bit confusing: if you are running a script from the command line, then the update to the source file should be noticed and the code reinterpreted.  I'm guessing you aren't running a standalone script, but are running and editing something out of an interpreter session that doesn't restart.  If this is correct then my statement above applies.  If not, you can give more details, but I doubt that there is a real python bug here so I'm closing the issue.  It can always be reopened if it turns out I'm wrong.
msg111761 - (view) Author: Guy (Guy) Date: 2010-07-28 01:53
I was running a script that I was editing, and, after making changes, the code wasn't reinterpreted, but listed the line that the "error" occured on (I had corrected the error on the file that was on disk, but yet, Python didn't reinterpret the code).

"I'm guessing you aren't running a standalone script, but are running and editing something out of an interpreter session that doesn't restart" - do you mean that it's assumed I will restart the session after a change to the code?  Judging by the data the traceback shows, wouldn't the results of the traceback/exception be misleading, citing a line of Python code on disk that was interpreted differently in memory?
msg111768 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-07-28 03:32
Yes, when you change the code on disk, you must restart the Python interpreter in order for it to "see" those changes.  And as I said, the source code is never held in memory, so the only source code the traceback can show is what is on disk.  This is just how Python works, it is not a bug.

To learn more about this, you should ask questions on the python-list mailing list.
History
Date User Action Args
2022-04-11 14:57:04adminsetgithub: 53635
2010-07-28 03:32:49r.david.murraysetstatus: open -> closed

messages: + msg111768
2010-07-28 01:53:03Guysetstatus: closed -> open

messages: + msg111761
2010-07-28 00:39:22r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg111752

resolution: not a bug
stage: resolved
2010-07-27 04:32:39Guycreate