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.

Title: Modules should alway have a dictionary
Type: behavior Stage: resolved
Components: Versions:
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Mark.Shannon Nosy List: Mark.Shannon
Priority: normal Keywords: patch

Created on 2021-06-22 09:53 by Mark.Shannon, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 26847 merged Mark.Shannon, 2021-06-22 10:00
Messages (2)
msg396316 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2021-06-22 09:53
It is possible to create a module without a dictionary:
m = types.ModuleType.__new__(types.ModuleType)

But that is the only way to create to a module without a dict; all other means of creating a module, both in Python and in the C API, result in a fully formed module.

Existing code expects that modules will always have a dictionary, e.g.

We should change types.ModuleType.__new__ to properly initialize the module.
msg396391 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2021-06-23 09:00
New changeset c3f52b4d707a78eb342372a2be00f3eb846a05b9 by Mark Shannon in branch 'main':
bpo-44486: Make sure that modules always have a dictionary. (GH-26847)
Date User Action Args
2022-04-11 14:59:47adminsetgithub: 88652
2021-06-23 16:33:40Mark.Shannonsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-06-23 09:00:51Mark.Shannonsetmessages: + msg396391
2021-06-22 10:00:48Mark.Shannonsetkeywords: + patch
stage: patch review
pull_requests: + pull_request25428
2021-06-22 09:53:42Mark.Shannoncreate