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:
Charlie Marsh 2023-08-14 13:39:44 -04:00 committed by GitHub
parent 09c8b17661
commit 96d310fbab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 70 additions and 489 deletions

View file

@ -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);
});
}