@@ -2007,9 +2007,8 @@ compiler_unwind_fblock(struct compiler *c, location *ploc,
2007
2007
/* This POP_BLOCK gets the line number of the unwinding statement */
2008
2008
ADDOP (c , * ploc , POP_BLOCK );
2009
2009
if (preserve_tos ) {
2010
- if (compiler_push_fblock (c , * ploc , POP_VALUE , NO_LABEL , NO_LABEL , NULL ) < 0 ) {
2011
- return ERROR ;
2012
- }
2010
+ RETURN_IF_ERROR (
2011
+ compiler_push_fblock (c , * ploc , POP_VALUE , NO_LABEL , NO_LABEL , NULL ));
2013
2012
}
2014
2013
/* Emit the finally block */
2015
2014
VISIT_SEQ (c , stmt , info -> fb_datum );
@@ -2041,9 +2040,7 @@ compiler_unwind_fblock(struct compiler *c, location *ploc,
2041
2040
if (preserve_tos ) {
2042
2041
ADDOP_I (c , * ploc , SWAP , 2 );
2043
2042
}
2044
- if (compiler_call_exit_with_nones (c , * ploc ) < 0 ) {
2045
- return ERROR ;
2046
- }
2043
+ RETURN_IF_ERROR (compiler_call_exit_with_nones (c , * ploc ));
2047
2044
if (info -> fb_type == ASYNC_WITH ) {
2048
2045
ADDOP_I (c , * ploc , GET_AWAITABLE , 2 );
2049
2046
ADDOP_LOAD_CONST (c , * ploc , Py_None );
@@ -2093,8 +2090,8 @@ compiler_unwind_fblock_stack(struct compiler *c, location *ploc,
2093
2090
}
2094
2091
struct fblockinfo * top = & c -> u -> u_fblock [c -> u -> u_nfblocks - 1 ];
2095
2092
if (top -> fb_type == EXCEPTION_GROUP_HANDLER ) {
2096
- return compiler_error (c , * ploc ,
2097
- "'break', 'continue' and 'return' cannot appear in an except* block" );
2093
+ return compiler_error (
2094
+ c , * ploc , "'break', 'continue' and 'return' cannot appear in an except* block" );
2098
2095
}
2099
2096
if (loop != NULL && (top -> fb_type == WHILE_LOOP || top -> fb_type == FOR_LOOP )) {
2100
2097
* loop = top ;
@@ -2353,7 +2350,9 @@ compiler_visit_kwonlydefaults(struct compiler *c, location loc,
2353
2350
goto error ;
2354
2351
}
2355
2352
}
2356
- RETURN_IF_ERROR (compiler_visit_expr (c , default_ ));
2353
+ if (compiler_visit_expr (c , default_ ) < 0 ) {
2354
+ goto error ;
2355
+ }
2357
2356
}
2358
2357
}
2359
2358
if (keys != NULL ) {
@@ -2445,26 +2444,30 @@ compiler_visit_annotations(struct compiler *c, location loc,
2445
2444
*/
2446
2445
Py_ssize_t annotations_len = 0 ;
2447
2446
2448
- if (compiler_visit_argannotations (c , args -> args , & annotations_len , loc ) < 0 )
2449
- return ERROR ;
2450
- if (compiler_visit_argannotations (c , args -> posonlyargs , & annotations_len , loc ) < 0 )
2451
- return ERROR ;
2452
- if (args -> vararg && args -> vararg -> annotation &&
2453
- compiler_visit_argannotation (c , args -> vararg -> arg ,
2454
- args -> vararg -> annotation , & annotations_len , loc ) < 0 )
2455
- return ERROR ;
2456
- if (compiler_visit_argannotations (c , args -> kwonlyargs , & annotations_len , loc ) < 0 )
2457
- return ERROR ;
2458
- if (args -> kwarg && args -> kwarg -> annotation &&
2459
- compiler_visit_argannotation (c , args -> kwarg -> arg ,
2460
- args -> kwarg -> annotation , & annotations_len , loc ) < 0 )
2461
- return ERROR ;
2447
+ RETURN_IF_ERROR (
2448
+ compiler_visit_argannotations (c , args -> args , & annotations_len , loc ));
2462
2449
2463
- if (compiler_visit_argannotation (c , & _Py_ID (return ), returns ,
2464
- & annotations_len , loc ) < 0 ) {
2465
- return ERROR ;
2450
+ RETURN_IF_ERROR (
2451
+ compiler_visit_argannotations (c , args -> posonlyargs , & annotations_len , loc ));
2452
+
2453
+ if (args -> vararg && args -> vararg -> annotation ) {
2454
+ RETURN_IF_ERROR (
2455
+ compiler_visit_argannotation (c , args -> vararg -> arg ,
2456
+ args -> vararg -> annotation , & annotations_len , loc ));
2457
+ }
2458
+
2459
+ RETURN_IF_ERROR (
2460
+ compiler_visit_argannotations (c , args -> kwonlyargs , & annotations_len , loc ));
2461
+
2462
+ if (args -> kwarg && args -> kwarg -> annotation ) {
2463
+ RETURN_IF_ERROR (
2464
+ compiler_visit_argannotation (c , args -> kwarg -> arg ,
2465
+ args -> kwarg -> annotation , & annotations_len , loc ));
2466
2466
}
2467
2467
2468
+ RETURN_IF_ERROR (
2469
+ compiler_visit_argannotation (c , & _Py_ID (return ), returns , & annotations_len , loc ));
2470
+
2468
2471
if (annotations_len ) {
2469
2472
ADDOP_I (c , loc , BUILD_TUPLE , annotations_len );
2470
2473
return 1 ;
@@ -2796,7 +2799,8 @@ compiler_class(struct compiler *c, stmt_ty s)
2796
2799
RETURN_IF_ERROR (compiler_apply_decorators (c , decos ));
2797
2800
2798
2801
/* 7. store into <name> */
2799
- return compiler_nameop (c , loc , s -> v .ClassDef .name , Store );
2802
+ RETURN_IF_ERROR (compiler_nameop (c , loc , s -> v .ClassDef .name , Store ));
2803
+ return SUCCESS ;
2800
2804
}
2801
2805
2802
2806
/* Return false if the expression is a constant value except named singletons.
@@ -3865,9 +3869,7 @@ compiler_import(struct compiler *c, stmt_ty s)
3865
3869
3866
3870
if (alias -> asname ) {
3867
3871
r = compiler_import_as (c , loc , alias -> name , alias -> asname );
3868
- if (r == ERROR ) {
3869
- return r ;
3870
- }
3872
+ RETURN_IF_ERROR (r );
3871
3873
}
3872
3874
else {
3873
3875
identifier tmp = alias -> name ;
@@ -4857,7 +4859,8 @@ validate_keywords(struct compiler *c, asdl_keyword_seq *keywords)
4857
4859
for (Py_ssize_t j = i + 1 ; j < nkeywords ; j ++ ) {
4858
4860
keyword_ty other = ((keyword_ty )asdl_seq_GET (keywords , j ));
4859
4861
if (other -> arg && !PyUnicode_Compare (key -> arg , other -> arg )) {
4860
- return compiler_error (c , LOC (other ), "keyword argument repeated: %U" , key -> arg );
4862
+ compiler_error (c , LOC (other ), "keyword argument repeated: %U" , key -> arg );
4863
+ return ERROR ;
4861
4864
}
4862
4865
}
4863
4866
}
@@ -6498,7 +6501,8 @@ validate_kwd_attrs(struct compiler *c, asdl_identifier_seq *attrs, asdl_pattern_
6498
6501
identifier other = ((identifier )asdl_seq_GET (attrs , j ));
6499
6502
if (!PyUnicode_Compare (attr , other )) {
6500
6503
location loc = LOC ((pattern_ty ) asdl_seq_GET (patterns , j ));
6501
- return compiler_error (c , loc , "attribute name repeated in class pattern: %U" , attr );
6504
+ compiler_error (c , loc , "attribute name repeated in class pattern: %U" , attr );
6505
+ return ERROR ;
6502
6506
}
6503
6507
}
6504
6508
}
@@ -6530,7 +6534,7 @@ compiler_pattern_class(struct compiler *c, pattern_ty p, pattern_context *pc)
6530
6534
}
6531
6535
VISIT (c , expr , p -> v .MatchClass .cls );
6532
6536
PyObject * attr_names = PyTuple_New (nattrs );
6533
- if (! attr_names ) {
6537
+ if (attr_names == NULL ) {
6534
6538
return ERROR ;
6535
6539
}
6536
6540
Py_ssize_t i ;
@@ -6647,7 +6651,9 @@ compiler_pattern_mapping(struct compiler *c, pattern_ty p,
6647
6651
compiler_error (c , LOC (p ), e );
6648
6652
goto error ;
6649
6653
}
6650
- RETURN_IF_ERROR (compiler_visit_expr (c , key ));
6654
+ if (compiler_visit_expr (c , key ) < 0 ) {
6655
+ goto error ;
6656
+ }
6651
6657
}
6652
6658
6653
6659
// all keys have been checked; there are no duplicates
@@ -6904,12 +6910,10 @@ compiler_pattern_sequence(struct compiler *c, pattern_ty p,
6904
6910
ADDOP (c , LOC (p ), POP_TOP );
6905
6911
}
6906
6912
else if (star_wildcard ) {
6907
- RETURN_IF_ERROR (
6908
- pattern_helper_sequence_subscr (c , LOC (p ), patterns , star , pc ));
6913
+ RETURN_IF_ERROR (pattern_helper_sequence_subscr (c , LOC (p ), patterns , star , pc ));
6909
6914
}
6910
6915
else {
6911
- RETURN_IF_ERROR (
6912
- pattern_helper_sequence_unpack (c , LOC (p ), patterns , star , pc ));
6916
+ RETURN_IF_ERROR (pattern_helper_sequence_unpack (c , LOC (p ), patterns , star , pc ));
6913
6917
}
6914
6918
return SUCCESS ;
6915
6919
}
@@ -6982,7 +6986,7 @@ compiler_match_inner(struct compiler *c, stmt_ty s, pattern_context *pc)
6982
6986
ADDOP_I (c , LOC (m -> pattern ), COPY , 1 );
6983
6987
}
6984
6988
pc -> stores = PyList_New (0 );
6985
- if (! pc -> stores ) {
6989
+ if (pc -> stores == NULL ) {
6986
6990
return ERROR ;
6987
6991
}
6988
6992
// Irrefutable cases must be either guarded, last, or both:
@@ -7009,9 +7013,7 @@ compiler_match_inner(struct compiler *c, stmt_ty s, pattern_context *pc)
7009
7013
// NOTE: Returning macros are safe again.
7010
7014
if (m -> guard ) {
7011
7015
RETURN_IF_ERROR (ensure_fail_pop (c , pc , 0 ));
7012
- RETURN_IF_ERROR (
7013
- compiler_jump_if (c , LOC (m -> pattern ), m -> guard ,
7014
- pc -> fail_pop [0 ], 0 ));
7016
+ RETURN_IF_ERROR (compiler_jump_if (c , LOC (m -> pattern ), m -> guard , pc -> fail_pop [0 ], 0 ));
7015
7017
}
7016
7018
// Success! Pop the subject off, we're done with it:
7017
7019
if (i != cases - has_default - 1 ) {
@@ -7037,8 +7039,7 @@ compiler_match_inner(struct compiler *c, stmt_ty s, pattern_context *pc)
7037
7039
ADDOP (c , LOC (m -> pattern ), NOP );
7038
7040
}
7039
7041
if (m -> guard ) {
7040
- RETURN_IF_ERROR (
7041
- compiler_jump_if (c , LOC (m -> pattern ), m -> guard , end , 0 ));
7042
+ RETURN_IF_ERROR (compiler_jump_if (c , LOC (m -> pattern ), m -> guard , end , 0 ));
7042
7043
}
7043
7044
VISIT_SEQ (c , stmt , m -> body );
7044
7045
}
0 commit comments