Skip to content

Commit fd03d97

Browse files
committed
impl syntaxerror
1 parent cadd656 commit fd03d97

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Lib/test/test_compile.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,8 +1536,6 @@ def test_try_except_as(self):
15361536
"""
15371537
self.check_stack_size(snippet)
15381538

1539-
# TODO: RUSTPYTHON
1540-
@unittest.expectedFailure
15411539
def test_try_except_star_qualified(self):
15421540
snippet = """
15431541
try:
@@ -1549,8 +1547,6 @@ def test_try_except_star_qualified(self):
15491547
"""
15501548
self.check_stack_size(snippet)
15511549

1552-
# TODO: RUSTPYTHON
1553-
@unittest.expectedFailure
15541550
def test_try_except_star_as(self):
15551551
snippet = """
15561552
try:
@@ -1562,8 +1558,6 @@ def test_try_except_star_as(self):
15621558
"""
15631559
self.check_stack_size(snippet)
15641560

1565-
# TODO: RUSTPYTHON
1566-
@unittest.expectedFailure
15671561
def test_try_except_star_finally(self):
15681562
snippet = """
15691563
try:

crates/codegen/src/compile.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2164,6 +2164,15 @@ impl Compiler {
21642164

21652165
// Compile exception type
21662166
if let Some(exc_type) = type_ {
2167+
// Check for unparenthesized tuple (e.g., `except* A, B:` instead of `except* (A, B):`)
2168+
if let Expr::Tuple(ExprTuple { elts, range, .. }) = exc_type.as_ref()
2169+
&& let Some(first) = elts.first()
2170+
&& range.start().to_u32() == first.range().start().to_u32()
2171+
{
2172+
return Err(self.error(CodegenErrorType::SyntaxError(
2173+
"multiple exception types must be parenthesized".to_owned(),
2174+
)));
2175+
}
21672176
self.compile_expression(exc_type)?;
21682177
} else {
21692178
return Err(self.error(CodegenErrorType::SyntaxError(

0 commit comments

Comments
 (0)