mirror of
https://github.com/python/cpython.git
synced 2025-07-27 13:14:41 +00:00
give a py3k warning when 'nonlocal' is used as a variable name
This commit is contained in:
parent
c756dcdd60
commit
399b1fe8df
3 changed files with 34 additions and 44 deletions
11
Python/ast.c
11
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue