From 17d16e128bcc91033eb5f387074f949236535361 Mon Sep 17 00:00:00 2001 From: Sam Gross Date: Sat, 14 Sep 2024 00:41:14 +0000 Subject: [PATCH] Try using _Py_dict_lookup_threadsafe --- Objects/dictobject.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 33cbe48847c086..5eafb4d6572df8 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -2483,17 +2483,21 @@ _PyDict_LoadGlobalStackRef(PyDictObject *globals, PyDictObject *builtins, PyObje } /* namespace 1: globals */ - ix = _Py_dict_lookup_threadsafe_stackref(globals, key, hash, res); + PyObject *value; + ix = _Py_dict_lookup_threadsafe(globals, key, hash, &value); if (ix == DKIX_ERROR) { + *res = PyStackRef_NULL; return; } - if (ix != DKIX_EMPTY && !PyStackRef_IsNull(*res)) { + if (ix != DKIX_EMPTY && value != NULL) { + *res = PyStackRef_FromPyObjectSteal(value); return; } /* namespace 2: builtins */ - ix = _Py_dict_lookup_threadsafe_stackref(builtins, key, hash, res); - assert(ix >= 0 || PyStackRef_IsNull(*res)); + ix = _Py_dict_lookup_threadsafe(builtins, key, hash, &value); + assert(ix >= 0 || value == NULL); + *res = PyStackRef_FromPyObjectSteal(value); } /* Consumes references to key and value */