diff options
author | Yury Selivanov <yury@magic.io> | 2016-09-15 12:50:23 -0400 |
---|---|---|
committer | Yury Selivanov <yury@magic.io> | 2016-09-15 12:50:23 -0400 |
commit | 75a546e4742311e7ed442e47410c55e57de71fd6 (patch) | |
tree | a38e0c81ace687cd1f4b737af4dc2d50131ce750 /Python | |
parent | d734fb01a2767352005604619186787d4fad1810 (diff) | |
download | cpython-75a546e4742311e7ed442e47410c55e57de71fd6.tar.gz |
Issue #26182: Raise DeprecationWarning for improper use of async/await keywords
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ast.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Python/ast.c b/Python/ast.c index 765d24e11b..deea579c0d 100644 --- a/Python/ast.c +++ b/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++) { |