[issue35857] Stacktrace shows lines from updated file on disk, not code actually running
Jonathan Fine
report at bugs.python.org
Wed Jan 30 06:36:16 EST 2019
Jonathan Fine <jfine2358 at gmail.com> 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 console.)
Suppose wibble.py contains a function fn. Now do
import wibble
fn = wibble.fn
# Modify and save wibble.py
reload(wibble)
fn()
It seems to me that
1) We have a mismatch between fn (in module __main__) and the file on disk.
2) Comparison will show that wibble.pyc is later than wibble.py.
3) There's no reliable way to discover that fn is not the current fn ...
4) ... other than comparing its bytecode with that of the current value of wibble.fn.
Regarding (4) there might be another method. But I can't think of one that's reliable.
----------
nosy: +jfine2358
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35857>
_______________________________________
More information about the Python-bugs-list
mailing list