Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Assert m_state != NULL to mimic GC traversal functions that do not correctly
handle module creation when the module state has not been created.
8 changes: 8 additions & 0 deletions Modules/_testmultiphase.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,14 @@ bad_traverse(PyObject *self, visitproc visit, void *arg) {
testmultiphase_state *m_state;

m_state = PyModule_GetState(self);

/* The following assertion mimics any traversal function that doesn't correctly handle
* the case during module creation where the module state hasn't been created yet.
*
* The check that it is used to test only runs in debug mode, so it is OK that the
* assert() will get compiled out in fully optimised release builds.
*/
assert(m_state != NULL);
Py_VISIT(m_state->integer);
return 0;
}
Expand Down