Skip to content

Commit 804b3ba

Browse files
committed
Reset PyPy end_* attributes manually
1 parent 2ccc9e7 commit 804b3ba

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

astroid/rebuilder.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,9 @@ def _reset_end_lineno(self, newnode: nodes.NodeNG) -> None:
225225
- ClassDef - For
226226
- FunctionDef - While
227227
- Call - If
228-
- Decorators - TryExcept
229-
- With - TryFinally
230-
- Assign
228+
- Decorators - Try
229+
- With - TryExcept
230+
- Assign - TryFinally
231231
"""
232232
newnode.end_lineno = None
233233
newnode.end_col_offset = None
@@ -1808,6 +1808,11 @@ def visit_try(
18081808
end_col_offset=getattr(node, "end_col_offset", None),
18091809
parent=parent,
18101810
)
1811+
if IS_PYPY and PY38:
1812+
# Reset end_* attributes manually since try_node isn't part
1813+
# of the final tree yet.
1814+
try_node.end_lineno = None
1815+
try_node.end_col_offset = None
18111816
if try_except:
18121817
try_node.postinit(
18131818
body=[*try_except.body],
@@ -1833,6 +1838,11 @@ def visit_try(
18331838
end_col_offset=getattr(node, "end_col_offset", None),
18341839
parent=parent,
18351840
)
1841+
if IS_PYPY and PY38:
1842+
# Reset end_* attributes manually since try_node isn't part
1843+
# of the final tree yet.
1844+
try_node.end_lineno = None
1845+
try_node.end_col_offset = None
18361846
try_node.postinit(
18371847
body=[*newnode.body],
18381848
handlers=[*newnode.handlers],

0 commit comments

Comments
 (0)