@@ -6506,11 +6506,9 @@ jump_to_fail_pop(struct compiler *c, location loc,
6506
6506
// Pop any items on the top of the stack, plus any objects we were going to
6507
6507
// capture on success:
6508
6508
Py_ssize_t pops = pc -> on_top + PyList_GET_SIZE (pc -> stores );
6509
- if (ensure_fail_pop (c , pc , pops ) < 0 ) {
6510
- return 0 ;
6511
- }
6512
- _ADDOP_JUMP (c , loc , op , pc -> fail_pop [pops ]);
6513
- return 1 ;
6509
+ RETURN_IF_ERROR (ensure_fail_pop (c , pc , pops ));
6510
+ ADDOP_JUMP (c , loc , op , pc -> fail_pop [pops ]);
6511
+ return SUCCESS ;
6514
6512
}
6515
6513
6516
6514
// Build all of the fail_pop blocks and reset fail_pop.
@@ -6775,7 +6773,9 @@ compiler_pattern_class(struct compiler *c, pattern_ty p, pattern_context *pc)
6775
6773
_ADDOP_I (c , LOC (p ), IS_OP , 1 );
6776
6774
// TOS is now a tuple of (nargs + nattrs) attributes (or None):
6777
6775
pc -> on_top ++ ;
6778
- RETURN_IF_FALSE (jump_to_fail_pop (c , LOC (p ), pc , POP_JUMP_IF_FALSE ));
6776
+ if (jump_to_fail_pop (c , LOC (p ), pc , POP_JUMP_IF_FALSE ) < 0 ) {
6777
+ return 0 ;
6778
+ }
6779
6779
_ADDOP_I (c , LOC (p ), UNPACK_SEQUENCE , nargs + nattrs );
6780
6780
pc -> on_top += nargs + nattrs - 1 ;
6781
6781
for (i = 0 ; i < nargs + nattrs ; i ++ ) {
@@ -6819,7 +6819,9 @@ compiler_pattern_mapping(struct compiler *c, pattern_ty p,
6819
6819
// We need to keep the subject on top during the mapping and length checks:
6820
6820
pc -> on_top ++ ;
6821
6821
_ADDOP (c , LOC (p ), MATCH_MAPPING );
6822
- RETURN_IF_FALSE (jump_to_fail_pop (c , LOC (p ), pc , POP_JUMP_IF_FALSE ));
6822
+ if (jump_to_fail_pop (c , LOC (p ), pc , POP_JUMP_IF_FALSE ) < 0 ) {
6823
+ return 0 ;
6824
+ }
6823
6825
if (!size && !star_target ) {
6824
6826
// If the pattern is just "{}", we're done! Pop the subject:
6825
6827
pc -> on_top -- ;
@@ -6831,7 +6833,9 @@ compiler_pattern_mapping(struct compiler *c, pattern_ty p,
6831
6833
_ADDOP (c , LOC (p ), GET_LEN );
6832
6834
_ADDOP_LOAD_CONST_NEW (c , LOC (p ), PyLong_FromSsize_t (size ));
6833
6835
_ADDOP_COMPARE (c , LOC (p ), GtE );
6834
- RETURN_IF_FALSE (jump_to_fail_pop (c , LOC (p ), pc , POP_JUMP_IF_FALSE ));
6836
+ if (jump_to_fail_pop (c , LOC (p ), pc , POP_JUMP_IF_FALSE ) < 0 ) {
6837
+ return 0 ;
6838
+ }
6835
6839
}
6836
6840
if (INT_MAX < size - 1 ) {
6837
6841
return compiler_error (c , LOC (p ), "too many sub-patterns in mapping pattern" );
@@ -6892,7 +6896,9 @@ compiler_pattern_mapping(struct compiler *c, pattern_ty p,
6892
6896
_ADDOP_I (c , LOC (p ), COPY , 1 );
6893
6897
_ADDOP_LOAD_CONST (c , LOC (p ), Py_None );
6894
6898
_ADDOP_I (c , LOC (p ), IS_OP , 1 );
6895
- RETURN_IF_FALSE (jump_to_fail_pop (c , LOC (p ), pc , POP_JUMP_IF_FALSE ));
6899
+ if (jump_to_fail_pop (c , LOC (p ), pc , POP_JUMP_IF_FALSE ) < 0 ) {
6900
+ return 0 ;
6901
+ }
6896
6902
// So far so good. Use that tuple of values on the stack to match
6897
6903
// sub-patterns against:
6898
6904
_ADDOP_I (c , LOC (p ), UNPACK_SEQUENCE , size );
@@ -7037,7 +7043,7 @@ compiler_pattern_or(struct compiler *c, pattern_ty p, pattern_context *pc)
7037
7043
old_pc .fail_pop = NULL ;
7038
7044
// No match. Pop the remaining copy of the subject and fail:
7039
7045
if ((cfg_builder_addop_noarg (CFG_BUILDER (c ), POP_TOP , LOC (p )) < 0 ) ||
7040
- ! jump_to_fail_pop (c , LOC (p ), pc , JUMP )) {
7046
+ jump_to_fail_pop (c , LOC (p ), pc , JUMP ) < 0 ) {
7041
7047
goto error ;
7042
7048
}
7043
7049
@@ -7114,20 +7120,26 @@ compiler_pattern_sequence(struct compiler *c, pattern_ty p,
7114
7120
// We need to keep the subject on top during the sequence and length checks:
7115
7121
pc -> on_top ++ ;
7116
7122
_ADDOP (c , LOC (p ), MATCH_SEQUENCE );
7117
- RETURN_IF_FALSE (jump_to_fail_pop (c , LOC (p ), pc , POP_JUMP_IF_FALSE ));
7123
+ if (jump_to_fail_pop (c , LOC (p ), pc , POP_JUMP_IF_FALSE ) < 0 ) {
7124
+ return 0 ;
7125
+ }
7118
7126
if (star < 0 ) {
7119
7127
// No star: len(subject) == size
7120
7128
_ADDOP (c , LOC (p ), GET_LEN );
7121
7129
_ADDOP_LOAD_CONST_NEW (c , LOC (p ), PyLong_FromSsize_t (size ));
7122
7130
_ADDOP_COMPARE (c , LOC (p ), Eq );
7123
- RETURN_IF_FALSE (jump_to_fail_pop (c , LOC (p ), pc , POP_JUMP_IF_FALSE ));
7131
+ if (jump_to_fail_pop (c , LOC (p ), pc , POP_JUMP_IF_FALSE ) < 0 ) {
7132
+ return 0 ;
7133
+ }
7124
7134
}
7125
7135
else if (size > 1 ) {
7126
7136
// Star: len(subject) >= size - 1
7127
7137
_ADDOP (c , LOC (p ), GET_LEN );
7128
7138
_ADDOP_LOAD_CONST_NEW (c , LOC (p ), PyLong_FromSsize_t (size - 1 ));
7129
7139
_ADDOP_COMPARE (c , LOC (p ), GtE );
7130
- RETURN_IF_FALSE (jump_to_fail_pop (c , LOC (p ), pc , POP_JUMP_IF_FALSE ));
7140
+ if (jump_to_fail_pop (c , LOC (p ), pc , POP_JUMP_IF_FALSE ) < 0 ) {
7141
+ return 0 ;
7142
+ }
7131
7143
}
7132
7144
// Whatever comes next should consume the subject:
7133
7145
pc -> on_top -- ;
@@ -7155,7 +7167,9 @@ compiler_pattern_value(struct compiler *c, pattern_ty p, pattern_context *pc)
7155
7167
}
7156
7168
_VISIT (c , expr , value );
7157
7169
_ADDOP_COMPARE (c , LOC (p ), Eq );
7158
- RETURN_IF_FALSE (jump_to_fail_pop (c , LOC (p ), pc , POP_JUMP_IF_FALSE ));
7170
+ if (jump_to_fail_pop (c , LOC (p ), pc , POP_JUMP_IF_FALSE ) < 0 ) {
7171
+ return 0 ;
7172
+ }
7159
7173
return 1 ;
7160
7174
}
7161
7175
@@ -7165,7 +7179,9 @@ compiler_pattern_singleton(struct compiler *c, pattern_ty p, pattern_context *pc
7165
7179
assert (p -> kind == MatchSingleton_kind );
7166
7180
_ADDOP_LOAD_CONST (c , LOC (p ), p -> v .MatchSingleton .value );
7167
7181
_ADDOP_COMPARE (c , LOC (p ), Is );
7168
- RETURN_IF_FALSE (jump_to_fail_pop (c , LOC (p ), pc , POP_JUMP_IF_FALSE ));
7182
+ if (jump_to_fail_pop (c , LOC (p ), pc , POP_JUMP_IF_FALSE ) < 0 ) {
7183
+ return 0 ;
7184
+ }
7169
7185
return 1 ;
7170
7186
}
7171
7187
0 commit comments