mirror of
https://github.com/python/cpython.git
synced 2025-10-06 23:21:06 +00:00
Issue #26182: Raise DeprecationWarning for improper use of async/await keywords
This commit is contained in:
parent
6775231597
commit
8987c9d219
6 changed files with 125 additions and 56 deletions
20
Python/ast.c
20
Python/ast.c
|
@ -938,6 +938,26 @@ forbidden_name(struct compiling *c, identifier name, const node *n,
|
|||
ast_error(c, n, "assignment to keyword");
|
||||
return 1;
|
||||
}
|
||||
if (PyUnicode_CompareWithASCIIString(name, "async") == 0 ||
|
||||
PyUnicode_CompareWithASCIIString(name, "await") == 0)
|
||||
{
|
||||
PyObject *message = PyUnicode_FromString(
|
||||
"'async' and 'await' will become reserved keywords"
|
||||
" in Python 3.7");
|
||||
if (message == NULL) {
|
||||
return 1;
|
||||
}
|
||||
if (PyErr_WarnExplicitObject(
|
||||
PyExc_DeprecationWarning,
|
||||
message,
|
||||
c->c_filename,
|
||||
LINENO(n),
|
||||
NULL,
|
||||
NULL) < 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (full_checks) {
|
||||
const char * const *p;
|
||||
for (p = FORBIDDEN; *p; p++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue