New submission from Mark Shannon <m...@hotpy.org>:

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.
https://github.com/python/cpython/blob/3.10/Include/internal/pycore_moduleobject.h#L35

We should change types.ModuleType.__new__ to properly initialize the module.

----------
assignee: Mark.Shannon
messages: 396316
nosy: Mark.Shannon
priority: normal
severity: normal
status: open
title: Modules should alway have a dictionary
type: behavior

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

Reply via email to