-
-
Notifications
You must be signed in to change notification settings - Fork 34.1k
Closed as not planned
Closed as not planned
Copy link
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-refactorCode refactoring (with no changes in behavior)Code refactoring (with no changes in behavior)
Description
In Python/interpconfig.c we use Py_DECREF(item); in line 118 here
static int
_config_dict_get_bool(PyObject *dict, const char *name, int *p_flag)
{
PyObject *item;
if (_config_dict_get(dict, name, &item) < 0) {
return -1;
}
// For now we keep things strict, rather than using PyObject_IsTrue().
int flag = item == Py_True;
if (!flag && item != Py_False) {
Py_DECREF(item);
config_dict_invalid_type(name);
return -1;
}
Py_DECREF(item);
*p_flag = flag;
return 0;
}
while it's not necessary here
Py_DECREF(item);
*p_flag = flag;
return 0;
because we use if (!flag && item != Py_False) and if this returns true, then we return and only in the other case we come to
Py_DECREF(item);
*p_flag = flag;
return 0;
which then means that
a. !flag is false which means that flag is true which means that item == PY_TRUE which doesn't have to be decremented
b. item == Py_FALSE which doesn't have to be decremented
c. both
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-refactorCode refactoring (with no changes in behavior)Code refactoring (with no changes in behavior)