Commit 1bf8845f authored by Michael Felt's avatar Michael Felt Committed by Miss Islington (bot)

bpo-34720: Fix test_importlib.test_bad_traverse for AIX (GH-9391)



Fix  Modules/_testmultiphase.c so that it exits with non-zero status on AIX just as other systems do (non zero exit status, e.g. as result of a segmentation fault) when a NULL pointer is accessed for data.


https://bugs.python.org/issue34720
parent 414c625a
Assert m_state != NULL to mimic GC traversal functions that do not correctly
handle module creation when the module state has not been created.
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment