mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
prefer clearing global objects to obscure module.__dict__ bugs #10068
This commit is contained in:
parent
11b1f3dac1
commit
5c4bfc4af0
4 changed files with 27 additions and 5 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue