From f134dab9a5f5ec5a697bae8fa2bc7113aa65f4d0 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Fri, 9 Jun 2023 23:20:27 +0200 Subject: [PATCH] gh-105375: Fix error handling in testcapi heaptype test Bail on first error in heapctypesubclasswithfinalizer_finalize() --- Modules/_testcapi/heaptype.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Modules/_testcapi/heaptype.c b/Modules/_testcapi/heaptype.c index 3488e35922c5ac..565ab570a42bde 100644 --- a/Modules/_testcapi/heaptype.c +++ b/Modules/_testcapi/heaptype.c @@ -661,8 +661,11 @@ heapctypesubclasswithfinalizer_finalize(PyObject *self) goto cleanup_finalize; } oldtype = PyObject_GetAttrString(m, "HeapCTypeSubclassWithFinalizer"); + if (oldtype == NULL) { + goto cleanup_finalize; + } newtype = PyObject_GetAttrString(m, "HeapCTypeSubclass"); - if (oldtype == NULL || newtype == NULL) { + if (newtype == NULL) { goto cleanup_finalize; }