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 jfine2358
Recipients Steve Pryde, jfine2358, steven.daprano
Date 2019-01-30.11:36:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1548848176.6.0.974767980802.issue35857@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2019-01-30 11:36:18jfine2358setrecipients: + jfine2358, steven.daprano, Steve Pryde
2019-01-30 11:36:16jfine2358setmessageid: <1548848176.6.0.974767980802.issue35857@roundup.psfhosted.org>
2019-01-30 11:36:16jfine2358linkissue35857 messages
2019-01-30 11:36:16jfine2358create