On 30/12/2012 12:31am, Eli Bendersky wrote:
Would it make sense to save the sys.modules state and restore it in
test___all__ so that sys.modules isn't affected by this test?

Deleting module objects can cause problems because the destructor replaces values in the globals dict by None. If anything defined there has "escaped" and depends on any globals then you are liable to encounter errors.

For example, setuptools restores sys.modules after running each test. This was causing errors at shutdown from an atexit function registered by multiprocessing. The atexit function was still registered, but no longer valid, because the module had been garbage collected and the globals had been replaced by None.

Personally I would like to get rid of the "purge globals" behaviour for modules deleted before shutdown has started: if someone manipulates sys.modules then they can just call gc.collect() if they want to promptly get rid of orphaned reference cycles.

--
Richard

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to