@@ -1954,55 +1954,6 @@ compiler_default_arguments(struct compiler *c, location loc,
1954
1954
return funcflags ;
1955
1955
}
1956
1956
1957
- static bool
1958
- forbidden_name (struct compiler * c , location loc , identifier name ,
1959
- expr_context_ty ctx )
1960
- {
1961
- if (ctx == Store && _PyUnicode_EqualToASCIIString (name , "__debug__" )) {
1962
- compiler_error (c , loc , "cannot assign to __debug__" );
1963
- return true;
1964
- }
1965
- if (ctx == Del && _PyUnicode_EqualToASCIIString (name , "__debug__" )) {
1966
- compiler_error (c , loc , "cannot delete __debug__" );
1967
- return true;
1968
- }
1969
- return false;
1970
- }
1971
-
1972
- static int
1973
- compiler_check_debug_one_arg (struct compiler * c , arg_ty arg )
1974
- {
1975
- if (arg != NULL ) {
1976
- if (forbidden_name (c , LOC (arg ), arg -> arg , Store )) {
1977
- return ERROR ;
1978
- }
1979
- }
1980
- return SUCCESS ;
1981
- }
1982
-
1983
- static int
1984
- compiler_check_debug_args_seq (struct compiler * c , asdl_arg_seq * args )
1985
- {
1986
- if (args != NULL ) {
1987
- for (Py_ssize_t i = 0 , n = asdl_seq_LEN (args ); i < n ; i ++ ) {
1988
- RETURN_IF_ERROR (
1989
- compiler_check_debug_one_arg (c , asdl_seq_GET (args , i )));
1990
- }
1991
- }
1992
- return SUCCESS ;
1993
- }
1994
-
1995
- static int
1996
- compiler_check_debug_args (struct compiler * c , arguments_ty args )
1997
- {
1998
- RETURN_IF_ERROR (compiler_check_debug_args_seq (c , args -> posonlyargs ));
1999
- RETURN_IF_ERROR (compiler_check_debug_args_seq (c , args -> args ));
2000
- RETURN_IF_ERROR (compiler_check_debug_one_arg (c , args -> vararg ));
2001
- RETURN_IF_ERROR (compiler_check_debug_args_seq (c , args -> kwonlyargs ));
2002
- RETURN_IF_ERROR (compiler_check_debug_one_arg (c , args -> kwarg ));
2003
- return SUCCESS ;
2004
- }
2005
-
2006
1957
static int
2007
1958
wrap_in_stopiteration_handler (struct compiler * c )
2008
1959
{
@@ -2267,7 +2218,6 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async)
2267
2218
type_params = s -> v .FunctionDef .type_params ;
2268
2219
}
2269
2220
2270
- RETURN_IF_ERROR (compiler_check_debug_args (c , args ));
2271
2221
RETURN_IF_ERROR (compiler_decorators (c , decos ));
2272
2222
2273
2223
firstlineno = s -> lineno ;
@@ -2910,8 +2860,6 @@ compiler_lambda(struct compiler *c, expr_ty e)
2910
2860
arguments_ty args = e -> v .Lambda .args ;
2911
2861
assert (e -> kind == Lambda_kind );
2912
2862
2913
- RETURN_IF_ERROR (compiler_check_debug_args (c , args ));
2914
-
2915
2863
location loc = LOC (e );
2916
2864
funcflags = compiler_default_arguments (c , loc , args );
2917
2865
if (funcflags == -1 ) {
@@ -4086,10 +4034,6 @@ compiler_nameop(struct compiler *c, location loc,
4086
4034
!_PyUnicode_EqualToASCIIString (name , "True" ) &&
4087
4035
!_PyUnicode_EqualToASCIIString (name , "False" ));
4088
4036
4089
- if (forbidden_name (c , loc , name , ctx )) {
4090
- return ERROR ;
4091
- }
4092
-
4093
4037
mangled = compiler_maybe_mangle (c , name );
4094
4038
if (!mangled ) {
4095
4039
return ERROR ;
@@ -4878,10 +4822,6 @@ validate_keywords(struct compiler *c, asdl_keyword_seq *keywords)
4878
4822
if (key -> arg == NULL ) {
4879
4823
continue ;
4880
4824
}
4881
- location loc = LOC (key );
4882
- if (forbidden_name (c , loc , key -> arg , Store )) {
4883
- return ERROR ;
4884
- }
4885
4825
for (Py_ssize_t j = i + 1 ; j < nkeywords ; j ++ ) {
4886
4826
keyword_ty other = ((keyword_ty )asdl_seq_GET (keywords , j ));
4887
4827
if (other -> arg && !PyUnicode_Compare (key -> arg , other -> arg )) {
@@ -6135,9 +6075,6 @@ compiler_visit_expr(struct compiler *c, expr_ty e)
6135
6075
ADDOP_NAME (c , loc , LOAD_ATTR , e -> v .Attribute .attr , names );
6136
6076
break ;
6137
6077
case Store :
6138
- if (forbidden_name (c , loc , e -> v .Attribute .attr , e -> v .Attribute .ctx )) {
6139
- return ERROR ;
6140
- }
6141
6078
ADDOP_NAME (c , loc , STORE_ATTR , e -> v .Attribute .attr , names );
6142
6079
break ;
6143
6080
case Del :
@@ -6331,9 +6268,6 @@ compiler_annassign(struct compiler *c, stmt_ty s)
6331
6268
}
6332
6269
switch (targ -> kind ) {
6333
6270
case Name_kind :
6334
- if (forbidden_name (c , loc , targ -> v .Name .id , Store )) {
6335
- return ERROR ;
6336
- }
6337
6271
/* If we have a simple name in a module or class, store annotation. */
6338
6272
if (s -> v .AnnAssign .simple &&
6339
6273
(c -> u -> u_scope_type == COMPILER_SCOPE_MODULE ||
@@ -6365,9 +6299,6 @@ compiler_annassign(struct compiler *c, stmt_ty s)
6365
6299
}
6366
6300
break ;
6367
6301
case Attribute_kind :
6368
- if (forbidden_name (c , loc , targ -> v .Attribute .attr , Store )) {
6369
- return ERROR ;
6370
- }
6371
6302
if (!s -> v .AnnAssign .value &&
6372
6303
check_ann_expr (c , targ -> v .Attribute .value ) < 0 ) {
6373
6304
return ERROR ;
@@ -6631,9 +6562,6 @@ pattern_helper_store_name(struct compiler *c, location loc,
6631
6562
ADDOP (c , loc , POP_TOP );
6632
6563
return SUCCESS ;
6633
6564
}
6634
- if (forbidden_name (c , loc , n , Store )) {
6635
- return ERROR ;
6636
- }
6637
6565
// Can't assign to the same name twice:
6638
6566
int duplicate = PySequence_Contains (pc -> stores , n );
6639
6567
RETURN_IF_ERROR (duplicate );
@@ -6791,10 +6719,6 @@ validate_kwd_attrs(struct compiler *c, asdl_identifier_seq *attrs, asdl_pattern_
6791
6719
Py_ssize_t nattrs = asdl_seq_LEN (attrs );
6792
6720
for (Py_ssize_t i = 0 ; i < nattrs ; i ++ ) {
6793
6721
identifier attr = ((identifier )asdl_seq_GET (attrs , i ));
6794
- location loc = LOC ((pattern_ty ) asdl_seq_GET (patterns , i ));
6795
- if (forbidden_name (c , loc , attr , Store )) {
6796
- return ERROR ;
6797
- }
6798
6722
for (Py_ssize_t j = i + 1 ; j < nattrs ; j ++ ) {
6799
6723
identifier other = ((identifier )asdl_seq_GET (attrs , j ));
6800
6724
if (!PyUnicode_Compare (attr , other )) {
0 commit comments