Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

GH-93662: Make sure that column offsets are correct in multi-line method calls. #93673

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
Jun 14, 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
Factor common code into a helper function.
  • Loading branch information
markshannon committed Jun 13, 2022
commit aac53a8c53ba31d683692eedad24f9ec19d72e72
22 changes: 12 additions & 10 deletions 22 Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -4801,6 +4801,16 @@ is_import_originated(struct compiler *c, expr_ty e)
return flags & DEF_IMPORT;
}

static void
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;
}
}

// Return 1 if the method call was optimized, -1 if not, and 0 on error.
static int
maybe_optimize_method_call(struct compiler *c, expr_ty e)
Expand Down Expand Up @@ -4843,11 +4853,7 @@ maybe_optimize_method_call(struct compiler *c, expr_ty e)
/* Alright, we can optimize the code. */
VISIT(c, expr, meth->v.Attribute.value);
SET_LOC(c, 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;
}
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 @@ -4858,11 +4864,7 @@ maybe_optimize_method_call(struct compiler *c, expr_ty e)
};
}
SET_LOC(c, e);
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;
}
update_location_to_match_attr(c, meth);
ADDOP_I(c, CALL, argsl + kwdsl);
return 1;
}
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.