diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-10-25 02:53:28 +0000 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-10-25 02:53:28 +0000 |
commit | 399b1fe8dff3be012a49390cf971f850cf4f41aa (patch) | |
tree | 78b0e46f05db28c05bb200f26332cb9c4222f51f /Python | |
parent | c756dcdd6086a5619e5acc0899197b01ae149e37 (diff) | |
download | cpython-git-399b1fe8dff3be012a49390cf971f850cf4f41aa.tar.gz |
give a py3k warning when 'nonlocal' is used as a variable name
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ast.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Python/ast.c b/Python/ast.c index 8414c74480..29b0e829d4 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -131,9 +131,14 @@ forbidden_check(struct compiling *c, const node *n, const char *x) { if (!strcmp(x, "None")) return ast_error(n, "assignment to None"); - if (Py_Py3kWarningFlag && !(strcmp(x, "True") && strcmp(x, "False")) && - !ast_warn(c, n, "assignment to True or False is forbidden in 3.x")) - return 0; + if (Py_Py3kWarningFlag) { + if (!(strcmp(x, "True") && strcmp(x, "False")) && + !ast_warn(c, n, "assignment to True or False is forbidden in 3.x")) + return 0; + if (!strcmp(x, "nonlocal") && + !ast_warn(c, n, "nonlocal is a keyword in 3.x")) + return 0; + } return 1; } |