diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-12-26-17-18-18.gh-issue-143201.UbXuX4.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-12-26-17-18-18.gh-issue-143201.UbXuX4.rst new file mode 100644 index 00000000000000..14ec47fa432e9f --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2025-12-26-17-18-18.gh-issue-143201.UbXuX4.rst @@ -0,0 +1 @@ +Print out the truncated line, not the raw sourceline. diff --git a/Python/_warnings.c b/Python/_warnings.c index d44d414bc93a04..1e9d88849bc219 100644 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -697,7 +697,7 @@ show_warning(PyThreadState *tstate, PyObject *filename, int lineno, if (truncated == NULL) goto error; - PyFile_WriteObject(sourceline, f_stderr, Py_PRINT_RAW); + PyFile_WriteObject(truncated, f_stderr, Py_PRINT_RAW); Py_DECREF(truncated); PyFile_WriteString("\n", f_stderr); }