8000 In get_source_line, replace _PyDict_GetItemWithError with PyDict_GetI… · python/cpython@cedf1cf · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit cedf1cf

Browse files
In get_source_line, replace _PyDict_GetItemWithError with PyDict_GetItemRef
1 parent 89e6f14 commit cedf1cf

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()
@@ -1066,12 +1065,12 @@ get_source_line(PyInterpreterState *interp, PyObject *module_globals, int lineno
10661065
return NULL;
10671066
}
10681067

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

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

0 commit comments

Comments
 (0)
0