We need to return immediately if there's an error during dictionary
lookup.
Also avoid the conditional-if operator. MSVC versions through v19.27 miscompile
compound literals with side effects within a conditional operator. This caused
crashes in the Windows10 buildbot.
{
PyObject *val;
Py_ssize_t ix = _Py_dict_lookup(mp, key, hash, &val);
- *value_addr = val == NULL ? PyStackRef_NULL : PyStackRef_FromPyObjectNew(val);
+ if (val == NULL) {
+ *value_addr = PyStackRef_NULL;
+ }
+ else {
+ *value_addr = PyStackRef_FromPyObjectNew(val);
+ }
return ix;
}
/* namespace 1: globals */
ix = _Py_dict_lookup_threadsafe_stackref(globals, key, hash, res);
if (ix == DKIX_ERROR) {
- *res = PyStackRef_NULL;
+ return;
}
if (ix != DKIX_EMPTY && !PyStackRef_IsNull(*res)) {
return;