Nick Coghlan <ncogh...@gmail.com> added the comment:

In the case of *dependencies* that get refreshed, no they're *not* kept in 
sys.modules - they get overwritten by the originals when the sys.modules state 
gets restored.

The problem almost certainly arises because something, somewhere is doing "from 
x import y", where y is a function that depends on module globals in 'x'.

If 'x' ever drops out of sys.modules (e.g. because it is a fresh copy only 
there temporarily during an import), the x.__dict__ will have every attribute 
set to None and calls to 'y' will fail. (In Florent's original example, it was 
his "dummy/foo.py" that set of alarm bells and prompted me to look up the 
reference for the module GC problem).


That's why I'm opposed to touching import_fresh_modules to sweep this problem 
under the rug - as long as module globals finalisation isn't GC based, keeping 
a reference to a function in a module without ensuring you also hold a 
reference to the module itself is always going to be somewhat dubious.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14035>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to