Skip to content

Commit 3899746

Browse files
committed
Simplify PyDict_SetDefaultRef result check in compile.c
1 parent 370587f commit 3899746

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

Python/compile.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -983,12 +983,9 @@ merge_consts_recursive(PyObject *const_cache, PyObject *o)
983983

984984
PyObject *t;
985985
int res = PyDict_SetDefaultRef(const_cache, key, key, &t);
986-
if (res < 0) {
987-
Py_DECREF(key);
988-
return NULL;
989-
}
990-
if (res == 1) {
991-
// o was already registered in const_cache. Just use it.
986+
if (res != 0) {
987+
// o was not inserted into const_cache. t is either the existing value
988+
// or NULL (on error).
992989
Py_DECREF(key);
993990
return t;
994991
}

0 commit comments

Comments
 (0)