This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Module dicts are wiped on module garbage collection
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.6, Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: iritkatriel, natedogith1, pablogsal, pitrou
Priority: normal Keywords:

Created on 2018-06-15 03:34 by natedogith1, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg319581 - (view) Author: (natedogith1) Date: 2018-06-15 03:34
When a module is garbage collected, it fills it's __dict__ with None.  issue19255 and issue18214 seem to suggest that this was fixed, along with github pull request 7140 (commit 196b0925ca55bf22ffbb97733cff3e63d4fb6e18).  However, this still seems to be an issue in 2.7.14 and 3.6.2.

>>> import sys
>>> a = type(sys)('a')
>>> b = a.__dict__
>>> b['__name__'] is None
False
>>> del a
>>> b['__name__'] is None
True
msg319648 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2018-06-15 19:02
I cannot reproduce this in 3.6.5:

>>>import sys
>>>import gc
>>>a = type(sys)('a')
>>>b = a.__dict__
>>>print(b['__name__'] is None)
False
>>>del a
>>>gc.collect()
>>>print(b['__name__'] is None)
False


On the other hand, this still happens in 2.7.15:

Python 2.7.15 (default, May  1 2018, 20:16:04)
[GCC 7.3.1 20180406] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>>import sys
>>>import gc
>>>a = type(sys)('a')
>>>b = a.__dict__
>>>print(b['__name__'] is None)
False
>>>del a
>>>gc.collect()
>>>print(b['__name__'] is None)
True
msg377485 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2020-09-25 10:44
I also can't reproduce it on a later version. If this is a 2.7/3.6 only problem, should the issue be closed?
History
Date User Action Args
2022-04-11 14:59:01adminsetgithub: 78048
2020-09-25 18:14:48serhiy.storchakasetstatus: open -> closed
resolution: out of date
stage: resolved
2020-09-25 10:44:14iritkatrielsetnosy: + iritkatriel
messages: + msg377485
2018-06-15 19:02:13pablogsalsetnosy: + pablogsal
messages: + msg319648
2018-06-15 08:59:07xiang.zhangsetnosy: + pitrou
2018-06-15 03:34:11natedogith1create