Visitar URL original
GH-94694: Fix column offsets for multi-line method lookups by brandtbucher · Pull Request #94697 · python/cpython · GitHub
Skip to content
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
Update comment
  • Loading branch information
brandtbucher committed Jul 8, 2022
commit 33dc4d8a911512fa310dc262b1c641f26c89cc9d
3 changes: 2 additions & 1 deletion Lib/test/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,8 @@ def test_complex_single_line_expression(self):
line=1, end_line=1, column=0, end_column=27, occurrence=4)

def test_multiline_assert_rewritten_as_method_call(self):
# GH-94694
# GH-94694: Copying location information from a "real" node to a
# handwritten one should always be valid!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it really always be valid?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can remove the comment if it's too controversial. It just seems to me that the utility/safety of ast.copy_location and ast.fix_missing_locations is dramatically reduced if they can't at least promise crash-free behavior.

tree = ast.parse("assert (\n42\n)")
old_node = tree.body[0]
new_node = ast.Expr(
Expand Down