10000 pattern_unpack_helper returns SUCCESS/ERROR · python/cpython@06ba665 · GitHub
[go: up one dir, main page]

Skip to content

Commit 06ba665

Browse files
committed
pattern_unpack_helper returns SUCCESS/ERROR
1 parent cbb63b0 commit 06ba665

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

Python/compile.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6595,30 +6595,35 @@ pattern_unpack_helper(struct compiler *c, location loc,
65956595
pattern_ty elt = asdl_seq_GET(elts, i);
65966596
if (elt->kind == MatchStar_kind && !seen_star) {
65976597
if ((i >= (1 << 8)) ||
6598-
(n-i-1 >= (INT_MAX >> 8)))
6599-
return compiler_error(c, loc,
6598+
(n-i-1 >= (INT_MAX >> 8))) {
6599+
compiler_error(c, loc,
66006600
"too many expressions in "
66016601
"star-unpacking sequence pattern");
6602-
_ADDOP_I(c, loc, UNPACK_EX, (i + ((n-i-1) << 8)));
6602+
return ERROR;
6603+
}
6604+
ADDOP_I(c, loc, UNPACK_EX, (i + ((n-i-1) << 8)));
66036605
seen_star = 1;
66046606
}
66056607
else if (elt->kind == MatchStar_kind) {
6606-
return compiler_error(c, loc,
6608+
compiler_error(c, loc,
66076609
"multiple starred expressions in sequence pattern");
6610+
return ERROR;
66086611
}
66096612
}
66106613
if (!seen_star) {
6611-
_ADDOP_I(c, loc, UNPACK_SEQUENCE, n);
6614+
ADDOP_I(c, loc, UNPACK_SEQUENCE, n);
66126615
}
6613-
return 1;
6616+
return SUCCESS;
66146617
}
66156618

66166619
static int
66176620
pattern_helper_sequence_unpack(struct compiler *c, location loc,
66186621
asdl_pattern_seq *patterns, Py_ssize_t star,
66196622
pattern_context *pc)
66206623
{
6621-
RETURN_IF_FALSE(pattern_unpack_helper(c, loc, patterns));
6624+
if (pattern_unpack_helper(c, loc, patterns) < 0) {
6625+
return 0;
6626+
}
66226627
Py_ssize_t size = asdl_seq_LEN(patterns);
66236628
// We've now got a bunch of new subjects on the stack. They need to remain
66246629
// there after each subpattern match:

0 commit comments

Comments
 (0)
0