summaryrefslogtreecommitdiffstats
path: root/Modules/_testmultiphase.c
diff options
context:
space:
mode:
authorMichael Felt <aixtools@users.noreply.github.com>2019-02-17 12:02:56 (GMT)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-02-17 12:02:56 (GMT)
commit1bf8845f74013c5f1cc5f49a11e52c652a1fb9dd (patch)
treee5bbf3e087331bb90ddf2866345012a5cb51f88e /Modules/_testmultiphase.c
parent414c625a7ea58943f0b1bc79d095d667d78db013 (diff)
downloadcpython-1bf8845f74013c5f1cc5f49a11e52c652a1fb9dd.zip
cpython-1bf8845f74013c5f1cc5f49a11e52c652a1fb9dd.tar.gz
cpython-1bf8845f74013c5f1cc5f49a11e52c652a1fb9dd.tar.bz2
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
Diffstat (limited to 'Modules/_testmultiphase.c')
-rw-r--r--Modules/_testmultiphase.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Modules/_testmultiphase.c b/Modules/_testmultiphase.c
index 5776df7..c6dfc2f 100644
--- a/Modules/_testmultiphase.c
+++ b/Modules/_testmultiphase.c
@@ -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;
}