Author Jim.Jewett
Recipients Jim.Jewett, chortos, dmascialino, eric.araujo, eric.snow, ezio.melotti, jjconti, loewis, ncoghlan, ubershmekel
Date 2012-02-14.16:01:47
SpamBayes Score 2.25067e-05
Marked as misclassified No
Message-id <>
Martin v. Löwis (loewis) wrote:

> Displaying a warning whenever the code has changed on disk is
> clearly unacceptable

As clarified, the request is only for when a traceback is being created (or perhaps even only for when one is being printed).  

I agree that we don't want to watch every file every time any code is run, but by the time a traceback is being displayed, any tight loops are ending.

Nick Coghlan (ncoghlan) wrote:

> There are a few different cases: ...
> 2. Source has been changed, but module has not been reloaded ...
> 3. Source has been changed, module has been reloaded, but object ...

Given that a traceback is being displayed, I think it is reasonable to rerun the find-module portion of import, and verify that there is not stale byte-code.  

Frankly, I think it would be worth storing a file timestamp on modules, and verifying that whatever-would-be-imported-if-imported-now matches that timestamp.  This would also catch case (3).

I also think that -- on traceback display -- it might be worth verifying that the code's __globals__ is the __globals__ associated with the module of that name in sys.modules.  This would warn about some intentional manipulations, but would catch case (3) even more accurately.
Date User Action Args
2012-02-14 16:01:49Jim.Jewettsetrecipients: + Jim.Jewett, loewis, ncoghlan, jjconti, ezio.melotti, eric.araujo, ubershmekel, chortos, dmascialino, eric.snow
2012-02-14 16:01:48Jim.Jewettsetmessageid: <>
2012-02-14 16:01:47Jim.Jewettlinkissue8087 messages
2012-02-14 16:01:47Jim.Jewettcreate