[issue35343] Importlib.reload has different behaviour in script and interactive mode

Brett Cannon report at bugs.python.org
Thu Nov 29 13:55:29 EST 2018


Brett Cannon <brett at python.org> added the comment:

It will because your file change happens so quickly by script that your file system isn't leading to a different mtime on the source, and so the bytecode isn't being regenerated. When you do it by hand you're physically slow enough to have the file copies take long enough for your file system to record the new mtime.

You can try using importlib.invalidate_caches() to help with this. Otherwise realize that importlib.reload() is really meant for interactive use and not script use anyway because it doesn't update old references to the module.

----------
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35343>
_______________________________________


More information about the Python-bugs-list mailing list