Skip to content

Commit

Permalink
Visit child nodes of TryStar
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls authored and Pierre-Sassoulas committed Mar 4, 2023
1 parent 0b4251a commit b2bc519
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion astroid/rebuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1823,13 +1823,20 @@ def visit_try(
return None

def visit_trystar(self, node: ast.TryStar, parent: NodeNG) -> nodes.TryStar:
return nodes.TryStar(
newnode = nodes.TryStar(
lineno=node.lineno,
col_offset=node.col_offset,
end_lineno=getattr(node, "end_lineno", None),
end_col_offset=getattr(node, "end_col_offset", None),
parent=parent,
)
newnode.postinit(
body=[self.visit_tryexcept(node, newnode)],
handlers=[self.visit(n, newnode) for n in node.handlers],
orelse=[self.visit(n, newnode) for n in node.orelse],
finalbody=[self.visit(n, newnode) for n in node.finalbody],
)
return newnode

def visit_tuple(self, node: ast.Tuple, parent: NodeNG) -> nodes.Tuple:
"""Visit a Tuple node by returning a fresh instance of it."""
Expand Down
2 changes: 1 addition & 1 deletion tests/test_group_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ def test_star_exceptions() -> None:
assert node.handlers
handler = node.handlers[0]
assert isinstance(handler, ExceptHandler)
assert handler.type.name == "ExceptionGroup"
assert handler.type.name == "ValueError"

0 comments on commit b2bc519

Please sign in to comment.