8000 gh-116664: Ensure thread-safe dict access in _warnings by erlend-aasland · Pull Request #116768 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-116664: Ensure thread-safe dict access in _warnings #116768

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Prev Previous commit
Next Next commit
In get_source_line, replace _PyDict_GetItemWithError with PyDict_GetI…
…temRef
  • Loading branch information
erlend-aasland committed Mar 13, 2024
commit 4d4371c782a6add47ac9197f67627874b7ffe043
7 changes: 3 additions & 4 deletions Python/_warnings.c
Original file line number Diff line number Diff line change
@@ -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 @@ -1065,12 +1064,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