From fece88d7f003d9136e04ad5384108b06ca3d234d Mon Sep 17 00:00:00 2001 From: Matt Page Date: Fri, 29 Mar 2024 14:14:54 -0700 Subject: [PATCH] Merge implementation of try_reuse_basic_ref --- Objects/weakrefobject.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c index fe7e6c2d735f52..480f4433b6a9f6 100644 --- a/Objects/weakrefobject.c +++ b/Objects/weakrefobject.c @@ -353,15 +353,10 @@ try_reuse_basic_ref(PyWeakReference *list, PyTypeObject *type, cand = proxy; } -#ifdef Py_GIL_DISABLED - if (cand != NULL && !_Py_TryIncref((PyObject *) cand)) { - cand = NULL; + if (cand != NULL && _Py_TryIncref((PyObject *) cand)) { + return cand; } -#else - Py_XINCREF(cand); -#endif - - return cand; + return NULL; } static int