gh-139640: Fix swallowing syntax warnings in different modules (GH-139755)

Revert GH-131993.

Fix swallowing some syntax warnings in different modules if they accidentally
have the same message and are emitted from the same line.
This commit is contained in:
Serhiy Storchaka 2025-10-14 17:48:09 +03:00 committed by GitHub
parent 1ff6d69fbe
commit 279db6bede
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 62 additions and 74 deletions

View file

@ -1962,8 +1962,8 @@ int
_PyErr_EmitSyntaxWarning(PyObject *msg, PyObject *filename, int lineno, int col_offset,
int end_lineno, int end_col_offset)
{
if (_PyErr_WarnExplicitObjectWithContext(PyExc_SyntaxWarning, msg,
filename, lineno) < 0)
if (PyErr_WarnExplicitObject(PyExc_SyntaxWarning, msg,
filename, lineno, NULL, NULL) < 0)
{
if (PyErr_ExceptionMatches(PyExc_SyntaxWarning)) {
/* Replace the SyntaxWarning exception with a SyntaxError