Skip to content

Commit

Permalink
In get_source_line, replace _PyDict_GetItemWithError with PyDict_GetI…
Browse files Browse the repository at this point in the history
…temRef
  • Loading branch information
erlend-aasland committed Mar 13, 2024
1 parent 89e6f14 commit cedf1cf
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Python/_warnings.c
@@ -1,5 +1,4 @@
#include "Python.h"
#include "pycore_dict.h" // _PyDict_GetItemWithError()
#include "pycore_interp.h" // PyInterpreterState.warnings
#include "pycore_long.h" // _PyLong_GetZero()
#include "pycore_pyerrors.h" // _PyErr_Occurred()
Expand Down Expand Up @@ -1066,12 +1065,12 @@ get_source_line(PyInterpreterState *interp, PyObject *module_globals, int lineno
return NULL;
}

module_name = _PyDict_GetItemWithError(module_globals, &_Py_ID(__name__));
if (!module_name) {
int rc = PyDict_GetItemRef(module_globals, &_Py_ID(__name__),
&module_name);
if (rc < 0 || rc == 0) {
Py_DECREF(loader);
return NULL;
}
Py_INCREF(module_name);

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

0 comments on commit cedf1cf

Please sign in to comment.