Skip to content

Commit 4d4371c

Browse files
In get_source_line, replace _PyDict_GetItemWithError with PyDict_GetItemRef
1 parent eeb0936 commit 4d4371c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Python/_warnings.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "Python.h"
2-
#include "pycore_dict.h" // _PyDict_GetItemWithError()
32
#include "pycore_interp.h" // PyInterpreterState.warnings
43
#include "pycore_long.h" // _PyLong_GetZero()
54
#include "pycore_pyerrors.h" // _PyErr_Occurred()
@@ -1065,12 +1064,12 @@ get_source_line(PyInterpreterState *interp, PyObject *module_globals, int lineno
10651064
return NULL;
10661065
}
10671066

1068-
module_name = _PyDict_GetItemWithError(module_globals, &_Py_ID(__name__));
1069-
if (!module_name) {
1067+
int rc = PyDict_GetItemRef(module_globals, &_Py_ID(__name__),
1068+
&module_name);
1069+
if (rc < 0 || rc == 0) {
10701070
Py_DECREF(loader);
10711071
return NULL;
10721072
}
1073-
Py_INCREF(module_name);
10741073

10751074
/* Make sure the loader implements the optional get_source() method. */
10761075
(void)PyObject_GetOptionalAttr(loader, &_Py_ID(get_source), &get_source);

0 commit comments

Comments
 (0)