Skip to content

Commit 42005e7

Browse files
committed
Fix more
1 parent 666443d commit 42005e7

3 files changed

Lines changed: 22 additions & 7 deletions

File tree

‎Lib/test/test_syntax.py‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@
10271027
SyntaxError: no binding for nonlocal 'x' found
10281028
10291029
From SF bug #1705365
1030-
>>> nonlocal x # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1030+
>>> nonlocal x
10311031
Traceback (most recent call last):
10321032
...
10331033
SyntaxError: nonlocal declaration not allowed at module level
@@ -1351,7 +1351,7 @@
13511351
13521352
Custom error messages for try blocks that are not followed by except/finally
13531353
1354-
>>> try: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1354+
>>> try:
13551355
... x = 34
13561356
...
13571357
Traceback (most recent call last):
@@ -2660,7 +2660,7 @@ def f(x: *b)
26602660
...
26612661
SyntaxError: yield expression cannot be used within the definition of a generic
26622662
2663-
>>> f(**x, *y) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
2663+
>>> f(**x, *y)
26642664
Traceback (most recent call last):
26652665
SyntaxError: iterable argument unpacking follows keyword argument unpacking
26662666
@@ -2936,18 +2936,15 @@ def test_bad_outdent(self):
29362936
"unindent does not match .* level",
29372937
subclass=IndentationError)
29382938

2939-
@unittest.expectedFailure # TODO: RUSTPYTHON
29402939
def test_kwargs_last(self):
29412940
self._check_error("int(base=10, '2')",
29422941
"positional argument follows keyword argument")
29432942

2944-
@unittest.expectedFailure # TODO: RUSTPYTHON
29452943
def test_kwargs_last2(self):
29462944
self._check_error("int(**{'base': 10}, '2')",
29472945
"positional argument follows "
29482946
"keyword argument unpacking")
29492947

2950-
@unittest.expectedFailure # TODO: RUSTPYTHON
29512948
def test_kwargs_last3(self):
29522949
self._check_error("int(**{'base': 10}, *['2'])",
29532950
"iterable argument unpacking follows "

‎crates/codegen/src/symboltable.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2941,7 +2941,7 @@ impl SymbolTableBuilder {
29412941
match role {
29422942
SymbolUsage::Nonlocal if scope_depth < 2 => {
29432943
return Err(SymbolTableError {
2944-
error: format!("cannot define nonlocal '{name}' at top level."),
2944+
error: "nonlocal declaration not allowed at module level".into(),
29452945
location,
29462946
});
29472947
}

‎crates/vm/src/vm/vm_new.rs‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,18 @@ impl SyntaxErrorInfo {
132132
"var-positional argument cannot have default value".into()
133133
}
134134

135+
ParseErrorType::PositionalAfterKeywordArgument => {
136+
"positional argument follows keyword argument".into()
137+
}
138+
139+
ParseErrorType::PositionalAfterKeywordUnpacking => {
140+
"positional argument follows keyword argument unpacking".into()
141+
}
142+
143+
ParseErrorType::InvalidArgumentUnpackingOrder => {
144+
"iterable argument unpacking follows keyword argument unpacking".into()
145+
}
146+
135147
ParseErrorType::OtherError(s)
136148
if s.eq_ignore_ascii_case(
137149
"bytes literal cannot be mixed with non-bytes literals",
@@ -192,6 +204,12 @@ impl SyntaxErrorInfo {
192204
"/ must be ahead of *".into()
193205
}
194206

207+
ParseErrorType::OtherError(s)
208+
if s.eq_ignore_ascii_case("Expected `except` or `finally` after `try` block") =>
209+
{
210+
"expected 'except' or 'finally' block".into()
211+
}
212+
195213
_ => return,
196214
};
197215

0 commit comments

Comments
 (0)