give a py3k warning when 'nonlocal' is used as a variable name

This commit is contained in:
Benjamin Peterson 2008-10-25 02:53:28 +00:00
parent c756dcdd60
commit 399b1fe8df
3 changed files with 34 additions and 44 deletions

View file

@ -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;
}