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.

Author vstinner
Recipients vstinner
Date 2020-03-02.09:52:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1583142742.19.0.316214627808.issue39824@roundup.psfhosted.org>
In-reply-to
Content
Currently, when a module implements m_traverse(), m_clear() or m_free(), these methods can be called with md_state=NULL even if the module implements the "Multi-phase extension module initialization" API (PEP 489).

I'm talking about these module methods:

* tp_traverse: module_traverse() calls md_def->m_traverse() if m_traverse is not NULL
* tp_clear: module_clear() calls md_def->m_clear() if m_clear is not NULL
* tp_dealloc: module_dealloc() calls md_def->m_free() is m_free is not NULL

Because of that, the implementation of these methods must check manually if md_state is NULL or not.

I propose to change module_traverse(), module_clear() and module_dealloc() to not call m_traverse(), m_clear() and m_free() if md_state is NULL and m_size > 0.

"m_size > 0" is an heuristic to check if the module implements the "Multi-phase extension module initialization" API (PEP 489). For example, the _pickle module doesn't fully implements the PEP 489: m_size > 0, but PyInit__pickle() uses PyModule_Create().

See bpo-32374 which documented that "m_traverse may be called with m_state=NULL" (GH-5140).
History
Date User Action Args
2020-03-02 09:52:22vstinnersetrecipients: + vstinner
2020-03-02 09:52:22vstinnersetmessageid: <1583142742.19.0.316214627808.issue39824@roundup.psfhosted.org>
2020-03-02 09:52:22vstinnerlinkissue39824 messages
2020-03-02 09:52:21vstinnercreate