mirror of
https://github.com/astral-sh/ruff
synced 2026-01-08 15:14:19 -05:00
Remove Stmt::TryStar (#6566)
## Summary Instead, we set an `is_star` flag on `Stmt::Try`. This is similar to the pattern we've migrated towards for `Stmt::For` (removing `Stmt::AsyncFor`) and friends. While these are significant differences for an interpreter, we tend to handle these cases identically or nearly identically. ## Test Plan `cargo test`
This commit is contained in:
@@ -513,6 +513,7 @@ impl<'a> Generator<'a> {
|
||||
handlers,
|
||||
orelse,
|
||||
finalbody,
|
||||
is_star,
|
||||
range: _,
|
||||
}) => {
|
||||
statement!({
|
||||
@@ -522,38 +523,7 @@ impl<'a> Generator<'a> {
|
||||
|
||||
for handler in handlers {
|
||||
statement!({
|
||||
self.unparse_except_handler(handler, false);
|
||||
});
|
||||
}
|
||||
|
||||
if !orelse.is_empty() {
|
||||
statement!({
|
||||
self.p("else:");
|
||||
});
|
||||
self.body(orelse);
|
||||
}
|
||||
if !finalbody.is_empty() {
|
||||
statement!({
|
||||
self.p("finally:");
|
||||
});
|
||||
self.body(finalbody);
|
||||
}
|
||||
}
|
||||
Stmt::TryStar(ast::StmtTryStar {
|
||||
body,
|
||||
handlers,
|
||||
orelse,
|
||||
finalbody,
|
||||
range: _,
|
||||
}) => {
|
||||
statement!({
|
||||
self.p("try:");
|
||||
});
|
||||
self.body(body);
|
||||
|
||||
for handler in handlers {
|
||||
statement!({
|
||||
self.unparse_except_handler(handler, true);
|
||||
self.unparse_except_handler(handler, *is_star);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user