@@ -1964,55 +1964,6 @@ compiler_default_arguments(struct compiler *c, location loc,
1964
1964
return funcflags ;
1965
1965
}
1966
1966
1967
- static bool
1968
- forbidden_name (struct compiler * c , location loc , identifier name ,
1969
- expr_context_ty ctx )
1970
- {
1971
- if (ctx == Store && _PyUnicode_EqualToASCIIString (name , "__debug__" )) {
1972
- compiler_error (c , loc , "cannot assign to __debug__" );
1973
- return true;
1974
- }
1975
- if (ctx == Del && _PyUnicode_EqualToASCIIString (name , "__debug__" )) {
1976
- compiler_error (c , loc , "cannot delete __debug__" );
1977
- return true;
1978
- }
1979
- return false;
1980
- }
1981
-
1982
- static int
1983
- compiler_check_debug_one_arg (struct compiler * c , arg_ty arg )
1984
- {
1985
- if (arg != NULL ) {
1986
- if (forbidden_name (c , LOC (arg ), arg -> arg , Store )) {
1987
- return ERROR ;
1988
- }
1989
- }
1990
- return SUCCESS ;
1991
- }
1992
-
1993
- static int
1994
- compiler_check_debug_args_seq (struct compiler * c , asdl_arg_seq * args )
1995
- {
1996
- if (args != NULL ) {
1997
- for (Py_ssize_t i = 0 , n = asdl_seq_LEN (args ); i < n ; i ++ ) {
1998
- RETURN_IF_ERROR (
1999
- compiler_check_debug_one_arg (c , asdl_seq_GET (args , i )));
2000
- }
2001
- }
2002
- return SUCCESS ;
2003
- }
2004
-
2005
- static int
2006
- compiler_check_debug_args (struct compiler * c , arguments_ty args )
2007
- {
2008
- RETURN_IF_ERROR (compiler_check_debug_args_seq (c , args -> posonlyargs ));
2009
- RETURN_IF_ERROR (compiler_check_debug_args_seq (c , args -> args ));
2010
- RETURN_IF_ERROR (compiler_check_debug_one_arg (c , args -> vararg ));
2011
- RETURN_IF_ERROR (compiler_check_debug_args_seq (c , args -> kwonlyargs ));
2012
- RETURN_IF_ERROR (compiler_check_debug_one_arg (c , args -> kwarg ));
2013
- return SUCCESS ;
2014
- }
2015
-
2016
1967
static int
2017
1968
wrap_in_stopiteration_handler (struct compiler * c )
2018
1969
{
@@ -2277,7 +2228,6 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async)
2277
2228
type_params = s -> v .FunctionDef .type_params ;
2278
2229
}
2279
2230
2280
- RETURN_IF_ERROR (compiler_check_debug_args (c , args ));
2281
2231
RETURN_IF_ERROR (compiler_decorators (c , decos ));
2282
2232
2283
2233
firstlineno = s -> lineno ;
@@ -2920,8 +2870,6 @@ compiler_lambda(struct compiler *c, expr_ty e)
2920
2870
arguments_ty args = e -> v .Lambda .args ;
2921
2871
assert (e -> kind == Lambda_kind );
2922
2872
2923
- RETURN_IF_ERROR (compiler_check_debug_args (c , args ));
2924
-
2925
2873
location loc = LOC (e );
2926
2874
funcflags = compiler_default_arguments (c , loc , args );
2927
2875
if (funcflags == -1 ) {
@@ -4096,10 +4044,6 @@ compiler_nameop(struct compiler *c, location loc,
4096
4044
!_PyUnicode_EqualToASCIIString (name , "True" ) &&
4097
4045
!_PyUnicode_EqualToASCIIString (name , "False" ));
4098
4046
4099
- if (forbidden_name (c , loc , name , ctx )) {
4100
- return ERROR ;
4101
- }
4102
-
4103
4047
mangled = compiler_maybe_mangle (c , name );
4104
4048
if (!mangled ) {
4105
4049
return ERROR ;
@@ -4905,10 +4849,6 @@ validate_keywords(struct compiler *c, asdl_keyword_seq *keywords)
4905
4849
if (key -> arg == NULL ) {
4906
4850
continue ;
4907
4851
}
4908
- location loc = LOC (key );
4909
- if (forbidden_name (c , loc , key -> arg , Store )) {
4910
- return ERROR ;
4911
- }
4912
4852
for (Py_ssize_t j = i + 1 ; j < nkeywords ; j ++ ) {
4913
4853
keyword_ty other = ((keyword_ty )asdl_seq_GET (keywords , j ));
4914
4854
if (other -> arg && !PyUnicode_Compare (key -> arg , other -> arg )) {
@@ -6180,9 +6120,6 @@ compiler_visit_expr(struct compiler *c, expr_ty e)
6180
6120
ADDOP_NAME (c , loc , LOAD_ATTR , e -> v .Attribute .attr , names );
6181
6121
break ;
6182
6122
case Store :
6183
- if (forbidden_name (c , loc , e -> v .Attribute .attr , e -> v .Attribute .ctx )) {
6184
- return ERROR ;
6185
- }
6186
6123
ADDOP_NAME (c , loc , STORE_ATTR , e -> v .Attribute .attr , names );
6187
6124
break ;
6188
6125
case Del :
@@ -6376,9 +6313,6 @@ compiler_annassign(struct compiler *c, stmt_ty s)
6376
6313
}
6377
6314
switch (targ -> kind ) {
6378
6315
case Name_kind :
6379
- if (forbidden_name (c , loc , targ -> v .Name .id , Store )) {
6380
- return ERROR ;
6381
- }
6382
6316
/* If we have a simple name in a module or class, store annotation. */
6383
6317
if (s -> v .AnnAssign .simple &&
6384
6318
(c -> u -> u_scope_type == COMPILER_SCOPE_MODULE ||
@@ -6410,9 +6344,6 @@ compiler_annassign(struct compiler *c, stmt_ty s)
6410
6344
}
6411
6345
break ;
6412
6346
case Attribute_kind :
6413
- if (forbidden_name (c , loc , targ -> v .Attribute .attr , Store )) {
6414
- return ERROR ;
6415
- }
6416
6347
if (!s -> v .AnnAssign .value &&
6417
6348
check_ann_expr (c , targ -> v .Attribute .value ) < 0 ) {
6418
6349
return ERROR ;
@@ -6676,9 +6607,6 @@ pattern_helper_store_name(struct compiler *c, location loc,
6676
6607
ADDOP (c , loc , POP_TOP );
6677
6608
return SUCCESS ;
6678
6609
}
6679
- if (forbidden_name (c , loc , n , Store )) {
6680
- return ERROR ;
6681
- }
6682
6610
// Can't assign to the same name twice:
6683
6611
int duplicate = PySequence_Contains (pc -> stores , n );
6684
6612
RETURN_IF_ERROR (duplicate );
@@ -6836,10 +6764,6 @@ validate_kwd_attrs(struct compiler *c, asdl_identifier_seq *attrs, asdl_pattern_
6836
6764
Py_ssize_t nattrs = asdl_seq_LEN (attrs );
6837
6765
for (Py_ssize_t i = 0 ; i < nattrs ; i ++ ) {
6838
6766
identifier attr = ((identifier )asdl_seq_GET (attrs , i ));
6839
- location loc = LOC ((pattern_ty ) asdl_seq_GET (patterns , i ));
6840
- if (forbidden_name (c , loc , attr , Store )) {
6841
- return ERROR ;
6842
- }
6843
6767
for (Py_ssize_t j = i + 1 ; j < nattrs ; j ++ ) {
6844
6768
identifier other = ((identifier )asdl_seq_GET (attrs , j ));
6845
6769
if (!PyUnicode_Compare (attr , other )) {
0 commit comments