bpo-44363: Get test_capi passing with address sanitizer (GH-26639)
(cherry picked from commit 31aa0dbff4c1d39c9d77c6c8f4a61d0e46c1268b)
Co-authored-by: Mark Shannon <mark@hotpy.org>
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index c759dcc..ef1fb71 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -4829,6 +4829,10 @@ check_pyobject_forbidden_bytes_is_freed(PyObject *self, PyObject *Py_UNUSED(args
static PyObject*
check_pyobject_freed_is_freed(PyObject *self, PyObject *Py_UNUSED(args))
{
+ /* This test would fail if run with the address sanitizer */
+#ifdef _Py_ADDRESS_SANITIZER
+ Py_RETURN_NONE;
+#else
PyObject *op = _PyObject_CallNoArg((PyObject *)&PyBaseObject_Type);
if (op == NULL) {
return NULL;
@@ -4838,6 +4842,7 @@ check_pyobject_freed_is_freed(PyObject *self, PyObject *Py_UNUSED(args))
Py_SET_REFCNT(op, 1);
/* object memory is freed! */
return test_pyobject_is_freed("check_pyobject_freed_is_freed", op);
+#endif
}