mirror of
https://github.com/python/cpython.git
synced 2025-07-08 03:45:36 +00:00
gh-119049: Fix incorrect display of warning which is constructed by C API (GH-119063)
The source line was not displayed if the warnings module had not yet been imported.
This commit is contained in:
parent
4702b7b5bd
commit
100c7ab00a
4 changed files with 57 additions and 4 deletions
|
@ -569,10 +569,9 @@ call_show_warning(PyThreadState *tstate, PyObject *category,
|
|||
PyObject *show_fn, *msg, *res, *warnmsg_cls = NULL;
|
||||
PyInterpreterState *interp = tstate->interp;
|
||||
|
||||
/* If the source parameter is set, try to get the Python implementation.
|
||||
The Python implementation is able to log the traceback where the source
|
||||
/* The Python implementation is able to log the traceback where the source
|
||||
was allocated, whereas the C implementation doesn't. */
|
||||
show_fn = GET_WARNINGS_ATTR(interp, _showwarnmsg, source != NULL);
|
||||
show_fn = GET_WARNINGS_ATTR(interp, _showwarnmsg, 1);
|
||||
if (show_fn == NULL) {
|
||||
if (PyErr_Occurred())
|
||||
return -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue