summaryrefslogtreecommitdiffstats
path: root/Parser/tokenizer.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2022-04-27 17:15:14 (GMT)
committerGitHub <noreply@github.com>2022-04-27 17:15:14 (GMT)
commit43a8bf1ea43127aa0d4d05f9db74827899808266 (patch)
tree906a7d4a0f551b97316c202d561d02de9ba0571f /Parser/tokenizer.c
parentf60b4c3d74f241775f80affe60dcba6448634fe3 (diff)
downloadcpython-43a8bf1ea43127aa0d4d05f9db74827899808266.zip
cpython-43a8bf1ea43127aa0d4d05f9db74827899808266.tar.gz
cpython-43a8bf1ea43127aa0d4d05f9db74827899808266.tar.bz2
gh-87999: Change warning type for numeric literal followed by keyword (GH-91980)
The warning emitted by the Python parser for a numeric literal immediately followed by keyword has been changed from deprecation warning to syntax warning.
Diffstat (limited to 'Parser/tokenizer.c')
-rw-r--r--Parser/tokenizer.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index db84e2e..c450aa8 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -1139,7 +1139,7 @@ indenterror(struct tok_state *tok)
}
static int
-parser_warn(struct tok_state *tok, const char *format, ...)
+parser_warn(struct tok_state *tok, PyObject *category, const char *format, ...)
{
PyObject *errmsg;
va_list vargs;
@@ -1154,9 +1154,9 @@ parser_warn(struct tok_state *tok, const char *format, ...)
goto error;
}
- if (PyErr_WarnExplicitObject(PyExc_DeprecationWarning, errmsg, tok->filename,
+ if (PyErr_WarnExplicitObject(category, errmsg, tok->filename,
tok->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();
@@ -1234,7 +1234,9 @@ verify_end_of_number(struct tok_state *tok, int c, const char *kind)
}
if (r) {
tok_backup(tok, c);
- if (parser_warn(tok, "invalid %s literal", kind)) {
+ if (parser_warn(tok, PyExc_SyntaxWarning,
+ "invalid %s literal", kind))
+ {
return 0;
}
tok_nextc(tok);