summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2016-09-15 16:50:23 (GMT)
committerYury Selivanov <yury@magic.io>2016-09-15 16:50:23 (GMT)
commit8987c9d219f0efb438f5d707a63d0a0a0f72b3ef (patch)
tree409543083b30dda1c786a619ab9012b0c9e0483f /Python
parent67752315979e1501b7088273b5a1aecc90b6fe67 (diff)
downloadcpython-8987c9d219f0efb438f5d707a63d0a0a0f72b3ef.zip
cpython-8987c9d219f0efb438f5d707a63d0a0a0f72b3ef.tar.gz
cpython-8987c9d219f0efb438f5d707a63d0a0a0f72b3ef.tar.bz2
Issue #26182: Raise DeprecationWarning for improper use of async/await keywords
Diffstat (limited to 'Python')
-rw-r--r--Python/ast.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/Python/ast.c b/Python/ast.c
index 765d24e..deea579 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++) {