summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorMartijn Pieters <github.com@zopatista.com>2017-08-22 20:16:23 (GMT)
committerƁukasz Langa <lukasz@langa.pl>2017-08-22 20:16:23 (GMT)
commit772d809a63f40fd35679da3fb115cdf7fa81bd20 (patch)
tree265d99b3470b6413666c5f2ce0e73dd564fb052e /Objects
parent5df8c589f4ec3d8c1ccd115dc030fa7596c1c75d (diff)
downloadcpython-772d809a63f40fd35679da3fb115cdf7fa81bd20.zip
cpython-772d809a63f40fd35679da3fb115cdf7fa81bd20.tar.gz
cpython-772d809a63f40fd35679da3fb115cdf7fa81bd20.tar.bz2
bpo-31161: only check for parens error for SyntaxError (#3082)
Subclasses such as IndentError and TabError should not have this message applied.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/exceptions.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index 190ad06..13c1be9 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -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;