8000 gh-99955: standardize return values of functions in assembler and optimizer. by iritkatriel · Pull Request #99956 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-99955: standardize return values of functions in assembler and optimizer. #99956

8000 New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 2, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
assemble_exception_table and assemble_emit_exception_table_entry retu…
…rn -1/0
  • Loading branch information
iritkatriel committed Dec 2, 2022
commit 72109381ff914731cf55a59250420fff36ee5802
19 changes: 12 additions & 7 deletions Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -7667,8 +7667,9 @@ assemble_emit_exception_table_entry(struct assembler *a, int start, int end, bas
{
Py_ssize_t len = PyBytes_GET_SIZE(a->a_except_table);
if (a->a_except_table_off + MAX_SIZE_OF_ENTRY >= len) {
if (_PyBytes_Resize(&a->a_except_table, len * 2) < 0)
return 0;
if (_PyBytes_Resize(&a->a_except_table, len * 2) < 0) {
return -1;
}
}
int size = end-start;
assert(end > start);
Expand All @@ -7683,7 +7684,7 @@ assemble_emit_exception_table_entry(struct assembler *a, int start, int end, bas
assemble_emit_exception_table_item(a, size, 0);
assemble_emit_exception_table_item(a, target, 0);
assemble_emit_exception_table_item(a, depth_lasti, 0);
return 1;
return 0;
}

static int
Expand All @@ -7699,7 +7700,9 @@ assemble_exception_table(struct assembler *a, basicblock *entryblock)
struct instr *instr = &b->b_instr[i];
if (instr->i_except != handler) {
if (handler != NULL) {
RETURN_IF_FALSE(assemble_emit_exception_table_entry(a, start, ioffset, handler));
if (assemble_emit_exception_table_entry(a, start, ioffset, handler) < 0) {
return -1;
}
}
start = ioffset;
handler = instr->i_except;
Expand All @@ -7708,9 +7711,11 @@ assemble_exception_table(struct assembler *a, basicblock *entryblock)
}
}
if (handler != NULL) {
RETURN_IF_FALSE(assemble_emit_exception_table_entry(a, start, ioffset, handler));
if (assemble_emit_exception_table_entry(a, start, ioffset, handler) < 0) {
return -1;
}
}
return 1;
return 0;
}

/* Code location emitting code. See locations.md for a description of the format. */
Expand Down Expand Up @@ -8916,7 +8921,7 @@ assemble(struct compiler *c, int addNone)
}
}

if (!assemble_exception_table(&a, g->g_entryblock)) {
if (assemble_exception_table(&a, g->g_entryblock) < 0) {
goto error;
}
if (_PyBytes_Resize(&a.a_except_table, a.a_except_table_off) < 0) {
Expand Down
0