Skip to content

Commit c8c59a1

Browse files
committed
gh-121459: Add missing return to _PyDict_LoadGlobalStackRef
We need to return immediately if there's an error during dictionary lookup. Also avoid the conditional-if operator. The Windows 10 buildbot seems to miscompile that for unknown reasons.
1 parent 3880917 commit c8c59a1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Objects/dictobject.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,7 +1550,12 @@ _Py_dict_lookup_threadsafe_stackref(PyDictObject *mp, PyObject *key, Py_hash_t h
15501550
{
15511551
PyObject *val;
15521552
Py_ssize_t ix = _Py_dict_lookup(mp, key, hash, &val);
1553-
*value_addr = val == NULL ? PyStackRef_NULL : PyStackRef_FromPyObjectNew(val);
1553+
if (val == NULL) {
1554+
*value_addr = PyStackRef_NULL;
1555+
}
1556+
else {
1557+
*value_addr = PyStackRef_FromPyObjectNew(val);
1558+
}
15541559
return ix;
15551560
}
15561561

@@ -2483,7 +2488,7 @@ _PyDict_LoadGlobalStackRef(PyDictObject *globals, PyDictObject *builtins, PyObje
24832488
/* namespace 1: globals */
24842489
ix = _Py_dict_lookup_threadsafe_stackref(globals, key, hash, res);
24852490
if (ix == DKIX_ERROR) {
2486-
*res = PyStackRef_NULL;
2491+
return;
24872492
}
24882493
if (ix != DKIX_EMPTY && !PyStackRef_IsNull(*res)) {
24892494
return;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy