prefer clearing global objects to obscure module.__dict__ bugs #10068

This commit is contained in:
Benjamin Peterson 2010-10-12 22:57:59 +00:00
parent 11b1f3dac1
commit 5c4bfc4af0
4 changed files with 27 additions and 5 deletions

View file

@ -654,6 +654,13 @@ Modules
Special read-only attribute: :attr:`__dict__` is the module's namespace as a
dictionary object.
.. impl-detail::
Because of the way CPython clears module dictionaries, the module
dictionary will be cleared when the module falls out of scope even if the
dictionary still has live references. To avoid this, copy the dictionary
or keep the module around while using its dictionary directly.
.. index::
single: __name__ (module attribute)
single: __doc__ (module attribute)