[New-bugs-announce] [issue32374] Document that m_traverse for multi-phase initialized modules can be called with m_state=NULL

Petr Viktorin report at bugs.python.org
Tue Dec 19 09:40:38 EST 2017


New submission from Petr Viktorin <encukou at gmail.com>:

After the create phase of multiphase initialization, the per-module state is NULL and the module object is reachable by the garbage collector. Between the create and exec phases, Python code is run and garbage collection can be triggered.
So, any custom m_traverse/m_clear/m_free function must be prepared to handle m_state being NULL. This is currently not well documented.

It might be useful to insert a call m_traverse after the first phase, at least in --with-pydebug mode, so the potential error gets triggered early.

----------
components: Extension Modules
messages: 308647
nosy: encukou
priority: normal
severity: normal
status: open
title: Document that m_traverse for multi-phase initialized modules can be called with m_state=NULL
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32374>
_______________________________________


More information about the New-bugs-announce mailing list