mirror of
https://github.com/python/cpython.git
synced 2025-09-09 18:32:22 +00:00
bpo-31161: only check for parens error for SyntaxError (#3082)
Subclasses such as IndentError and TabError should not have this message applied.
This commit is contained in:
parent
5df8c589f4
commit
772d809a63
3 changed files with 41 additions and 5 deletions
|
@ -1352,11 +1352,16 @@ SyntaxError_init(PySyntaxErrorObject *self, PyObject *args, PyObject *kwds)
|
|||
|
||||
Py_DECREF(info);
|
||||
|
||||
/* Issue #21669: Custom error for 'print' & 'exec' as statements */
|
||||
if (self->text && PyUnicode_Check(self->text)) {
|
||||
if (_report_missing_parentheses(self) < 0) {
|
||||
return -1;
|
||||
}
|
||||
/*
|
||||
* Issue #21669: Custom error for 'print' & 'exec' as statements
|
||||
*
|
||||
* Only applies to SyntaxError instances, not to subclasses such
|
||||
* as TabError or IndentationError (see issue #31161)
|
||||
*/
|
||||
if ((PyObject*)Py_TYPE(self) == PyExc_SyntaxError &&
|
||||
self->text && PyUnicode_Check(self->text) &&
|
||||
_report_missing_parentheses(self) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue