summaryrefslogtreecommitdiffstats
path: root/Parser/string_parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'Parser/string_parser.c')
-rw-r--r--Parser/string_parser.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/Parser/string_parser.c b/Parser/string_parser.c
index 9bc3b08..e13272c 100644
--- a/Parser/string_parser.c
+++ b/Parser/string_parser.c
@@ -21,9 +21,16 @@ warn_invalid_escape_sequence(Parser *p, const char *first_invalid_escape, Token
if (msg == NULL) {
return -1;
}
- if (PyErr_WarnExplicitObject(PyExc_DeprecationWarning, msg, p->tok->filename,
+ PyObject *category;
+ if (p->feature_version >= 12) {
+ category = PyExc_SyntaxWarning;
+ }
+ else {
+ category = PyExc_DeprecationWarning;
+ }
+ if (PyErr_WarnExplicitObject(category, msg, p->tok->filename,
t->lineno, NULL, NULL) < 0) {
- if (PyErr_ExceptionMatches(PyExc_DeprecationWarning)) {
+ if (PyErr_ExceptionMatches(category)) {
/* Replace the DeprecationWarning exception with a SyntaxError
to get a more accurate error report */
PyErr_Clear();