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.

Author gregory.p.smith
Recipients gregory.p.smith
Date 2021-05-09.17:15:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1620580530.62.0.599288030317.issue44091@roundup.psfhosted.org>
In-reply-to
Content
A long-standing wart in Python is that once a module is loaded, when rendering a traceback and including source lines, we do not verify if the source file we're loading is the same as the one representing the code we are running.

It could have been replaced.  As is normal during software upgrades.

If our code was loaded from .py source, we should be recording the timestamp/size||hash of the source file and referencing that from each code object.  If our code was loaded from a .pyc source, the .pyc already contains a timestamp/size||hash for the corresponding .py source file that could be referenced.

When traceback.StackSummary and FrameSummary use the linecache module, we should plumb this source metainfo in from the relevant code object.

A traceback being rendered with potentially modified source code could choose to omit the source lines, or at least annotate them with a "  ## this source {timestamp/size||hash} does not match the running code {timestamp/size||hash}." marker so that anyone seeing the traceback knows the displayed line may not be trustworthy.  (If the pyc was written using the "unchecked-hash" mode, no source/pyc synchronization check should be made)

The inspect module also needs the ability to do indicate this to the caller.
History
Date User Action Args
2021-05-09 17:15:30gregory.p.smithsetrecipients: + gregory.p.smith
2021-05-09 17:15:30gregory.p.smithsetmessageid: <1620580530.62.0.599288030317.issue44091@roundup.psfhosted.org>
2021-05-09 17:15:30gregory.p.smithlinkissue44091 messages
2021-05-09 17:15:30gregory.p.smithcreate