New submission from Petr Viktorin <encu...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue32374>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to