Serhiy Storchaka added the comment:

There are no guaranties. But in recent Python versions the order of finalising 
is more predicable. It is hard to reproduce a case when some builtins or sys 
member is not available (with some exceptions).

The order of clearing (see PyImport_Cleanup() in Python/import.c):

1. Clear builtins._ and selected sys members (in particular this breaks 
import). Restore standard IO streams.

2. Clear sys.modules and all modules that don't have external references.

3. Restore builtins to its initial state (in particular builtins.open no longer 
available).

4. Clear the content of still alive modules except sys and builtins.

5. Clear sys.

6. Clear builtins.

----------

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

Reply via email to