Visitar URL original
GH-93678: reduce boilerplate and code repetition in the compiler by iritkatriel · Pull Request #93682 · python/cpython · GitHub
Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
Merge remote-tracking branch 'upstream/main' into codegen-reduce-repe…
…tition
  • Loading branch information
iritkatriel committed Jun 14, 2022
commit 98d24f2e6355c1fc42c4b95f26be7e9437e161c8
11 changes: 5 additions & 6 deletions Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -4728,8 +4728,8 @@ update_location_to_match_attr(struct compiler *c, expr_ty meth)
{
if (meth->lineno != meth->end_lineno) {
// Make start location match attribute
c->u->u_lineno = meth->end_lineno;
c->u->u_col_offset = meth->end_col_offset - (int)PyUnicode_GetLength(meth->v.Attribute.attr)-1;
c->u->u_loc.lineno = meth->end_lineno;
c->u->u_loc.col_offset = meth->end_col_offset - (int)PyUnicode_GetLength(meth->v.Attribute.attr)-1;
}
}

Expand Down Expand Up @@ -4774,8 +4774,8 @@ maybe_optimize_method_call(struct compiler *c, expr_ty e)
}
/* Alright, we can optimize the code. */
VISIT(c, expr, meth->v.Attribute.value);
int old_lineno = c->u->u_loc.lineno;
c->u->u_loc.lineno = meth->end_lineno;
SET_LOC(c, meth);
update_location_to_match_attr(c, meth);
ADDOP_NAME(c, LOAD_METHOD, meth->v.Attribute.attr, names);
VISIT_SEQ(c, expr, e->v.Call.args);

Expand All @@ -4788,7 +4788,6 @@ maybe_optimize_method_call(struct compiler *c, expr_ty e)
SET_LOC(c, e);
update_location_to_match_attr(c, meth);
ADDOP_I(c, CALL, argsl + kwdsl);
c->u->u_loc.lineno = old_lineno;
return 1;
}

Expand Down Expand Up @@ -7666,7 +7665,7 @@ write_location_info_entry(struct assembler* a, struct instr* i, int isize)
}
}
else if (i->i_loc.end_lineno == i->i_loc.lineno) {
if (line_delta == 0 && column < 80 && end_column - column < 16) {
if (line_delta == 0 && column < 80 && end_column - column < 16 && end_column >= column) {
write_location_info_short_form(a, isize, column, end_column);
return 1;
}
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.