Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit acd6f41

Browse filesBrowse files
gh-111789: Use PyDict_GetItemRef() in Python/compile.c (GH-112083)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
1 parent e74cd0f commit acd6f41
Copy full SHA for acd6f41

File tree

Expand file treeCollapse file tree

1 file changed

+4
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-5
lines changed

‎Python/compile.c

Copy file name to clipboardExpand all lines: Python/compile.c
+4-5Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -921,11 +921,10 @@ dict_add_o(PyObject *dict, PyObject *o)
921921
PyObject *v;
922922
Py_ssize_t arg;
923923

924-
v = PyDict_GetItemWithError(dict, o);
924+
if (PyDict_GetItemRef(dict, o, &v) < 0) {
925+
return ERROR;
926+
}
925927
if (!v) {
926-
if (PyErr_Occurred()) {
927-
return ERROR;
928-
}
929928
arg = PyDict_GET_SIZE(dict);
930929
v = PyLong_FromSsize_t(arg);
931930
if (!v) {
@@ -935,10 +934,10 @@ dict_add_o(PyObject *dict, PyObject *o)
935934
Py_DECREF(v);
936935
return ERROR;
937936
}
938-
Py_DECREF(v);
939937
}
940938
else
941939
arg = PyLong_AsLong(v);
940+
Py_DECREF(v);
942941
return arg;
943942
}
944943

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.