Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/test/test_metaclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@

Check for duplicate keywords.

>>> class C(metaclass=type, metaclass=type): pass # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
>>> class C(metaclass=type, metaclass=type): pass
...
Traceback (most recent call last):
[...]
Expand Down
3 changes: 0 additions & 3 deletions Lib/test/test_named_expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,20 @@ def test_named_expression_invalid_10(self):
with self.assertRaisesRegex(SyntaxError, "invalid syntax"):
exec(code, {}, {})

@unittest.expectedFailure # TODO: RUSTPYTHON; wrong error message
def test_named_expression_invalid_11(self):
code = """spam(a=1, b := 2)"""

with self.assertRaisesRegex(SyntaxError,
"positional argument follows keyword argument"):
exec(code, {}, {})

@unittest.expectedFailure # TODO: RUSTPYTHON; wrong error message
def test_named_expression_invalid_12(self):
code = """spam(a=1, (b := 2))"""

with self.assertRaisesRegex(SyntaxError,
"positional argument follows keyword argument"):
exec(code, {}, {})

@unittest.expectedFailure # TODO: RUSTPYTHON; wrong error message
def test_named_expression_invalid_13(self):
code = """spam(a=1, (b := 2))"""

Expand Down
3 changes: 0 additions & 3 deletions Lib/test/test_positional_only_arg.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def assertRaisesSyntaxError(self, codestr, regex="invalid syntax"):
with self.assertRaisesRegex(SyntaxError, regex):
compile(codestr + "\n", "<test>", "single")

@unittest.expectedFailure # TODO: RUSTPYTHON; wrong error message
def test_invalid_syntax_errors(self):
check_syntax_error(self, "def f(a, b = 5, /, c): pass", "parameter without a default follows parameter with a default")
check_syntax_error(self, "def f(a = 5, b, /, c): pass", "parameter without a default follows parameter with a default")
Expand All @@ -46,7 +45,6 @@ def test_invalid_syntax_errors(self):
check_syntax_error(self, "def f(a, /, c, /, d, *, e): pass")
check_syntax_error(self, "def f(a, *, c, /, d, e): pass")

@unittest.expectedFailure # TODO: RUSTPYTHON; wrong error message
def test_invalid_syntax_errors_async(self):
check_syntax_error(self, "async def f(a, b = 5, /, c): pass", "parameter without a default follows parameter with a default")
check_syntax_error(self, "async def f(a = 5, b, /, c): pass", "parameter without a default follows parameter with a default")
Expand Down Expand Up @@ -235,7 +233,6 @@ def test_lambdas(self):
x = lambda a, b, /, : a + b
self.assertEqual(x(1, 2), 3)

@unittest.expectedFailure # TODO: RUSTPYTHON; wrong error message
def test_invalid_syntax_lambda(self):
check_syntax_error(self, "lambda a, b = 5, /, c: None", "parameter without a default follows parameter with a default")
check_syntax_error(self, "lambda a = 5, b, /, c: None", "parameter without a default follows parameter with a default")
Expand Down
96 changes: 45 additions & 51 deletions Lib/test/test_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,12 +398,12 @@

From ast_for_arguments():

>>> def f(x, y=1, z): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> def f(x, y=1, z):
... pass
Traceback (most recent call last):
SyntaxError: parameter without a default follows parameter with a default

>>> def f(x, /, y=1, z): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> def f(x, /, y=1, z):
... pass
Traceback (most recent call last):
SyntaxError: parameter without a default follows parameter with a default
Expand All @@ -423,47 +423,47 @@
Traceback (most recent call last):
SyntaxError: invalid syntax

>>> def foo(/,a,b=,c): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> def foo(/,a,b=,c):
... pass
Traceback (most recent call last):
SyntaxError: at least one argument must precede /

>>> def foo(a,/,/,b,c): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> def foo(a,/,/,b,c):
... pass
Traceback (most recent call last):
SyntaxError: / may appear only once

>>> def foo(a,/,a1,/,b,c): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> def foo(a,/,a1,/,b,c):
... pass
Traceback (most recent call last):
SyntaxError: / may appear only once

>>> def foo(a=1,/,/,*b,/,c): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> def foo(a=1,/,/,*b,/,c):
... pass
Traceback (most recent call last):
SyntaxError: / may appear only once

>>> def foo(a,/,a1=1,/,b,c): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> def foo(a,/,a1=1,/,b,c):
... pass
Traceback (most recent call last):
SyntaxError: / may appear only once

>>> def foo(a,*b,c,/,d,e): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> def foo(a,*b,c,/,d,e):
... pass
Traceback (most recent call last):
SyntaxError: / must be ahead of *

>>> def foo(a=1,*b,c=3,/,d,e): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> def foo(a=1,*b,c=3,/,d,e):
... pass
Traceback (most recent call last):
SyntaxError: / must be ahead of *

>>> def foo(a,*b=3,c): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> def foo(a,*b=3,c):
... pass
Traceback (most recent call last):
SyntaxError: var-positional argument cannot have default value

>>> def foo(a,*b: int=,c): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> def foo(a,*b: int=,c):
... pass
Traceback (most recent call last):
SyntaxError: var-positional argument cannot have default value
Expand Down Expand Up @@ -543,39 +543,39 @@
Traceback (most recent call last):
SyntaxError: expected default value expression

>>> lambda /,a,b,c: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> lambda /,a,b,c: None
Traceback (most recent call last):
SyntaxError: at least one argument must precede /

>>> lambda a,/,/,b,c: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> lambda a,/,/,b,c: None
Traceback (most recent call last):
SyntaxError: / may appear only once

>>> lambda a,/,a1,/,b,c: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> lambda a,/,a1,/,b,c: None
Traceback (most recent call last):
SyntaxError: / may appear only once

>>> lambda a=1,/,/,*b,/,c: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> lambda a=1,/,/,*b,/,c: None
Traceback (most recent call last):
SyntaxError: / may appear only once

>>> lambda a,/,a1=1,/,b,c: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> lambda a,/,a1=1,/,b,c: None
Traceback (most recent call last):
SyntaxError: / may appear only once

>>> lambda a,*b,c,/,d,e: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> lambda a,*b,c,/,d,e: None
Traceback (most recent call last):
SyntaxError: / must be ahead of *

>>> lambda a=1,*b,c=3,/,d,e: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> lambda a=1,*b,c=3,/,d,e: None
Traceback (most recent call last):
SyntaxError: / must be ahead of *

>>> lambda a=1,/*,b,c: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
Traceback (most recent call last):
SyntaxError: expected comma between / and *

>>> lambda a,*b=3,c: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> lambda a,*b=3,c: None
Traceback (most recent call last):
SyntaxError: var-positional argument cannot have default value

Expand Down Expand Up @@ -627,11 +627,11 @@
Traceback (most recent call last):
SyntaxError: expected default value expression

>>> lambda a,d=3,c: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> lambda a,d=3,c: None
Traceback (most recent call last):
SyntaxError: parameter without a default follows parameter with a default

>>> lambda a,/,d=3,c: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> lambda a,/,d=3,c: None
Traceback (most recent call last):
SyntaxError: parameter without a default follows parameter with a default

Expand Down Expand Up @@ -661,25 +661,25 @@
>>> L = range(10)
>>> f(x for x in L)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> f(x for x in L, 1) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> f(x for x in L, 1)
Traceback (most recent call last):
SyntaxError: Generator expression must be parenthesized
>>> f(x for x in L, y=1) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> f(x for x in L, y=1)
Traceback (most recent call last):
SyntaxError: Generator expression must be parenthesized
>>> f(x for x in L, *[]) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> f(x for x in L, *[])
Traceback (most recent call last):
SyntaxError: Generator expression must be parenthesized
>>> f(x for x in L, **{}) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> f(x for x in L, **{})
Traceback (most recent call last):
SyntaxError: Generator expression must be parenthesized
>>> f(L, x for x in L) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> f(L, x for x in L)
Traceback (most recent call last):
SyntaxError: Generator expression must be parenthesized
>>> f(x for x in L, y for y in L) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> f(x for x in L, y for y in L)
Traceback (most recent call last):
SyntaxError: Generator expression must be parenthesized
>>> f(x for x in L,) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> f(x for x in L,)
Traceback (most recent call last):
SyntaxError: Generator expression must be parenthesized
>>> f((x for x in L), 1)
Expand Down Expand Up @@ -1027,7 +1027,7 @@
SyntaxError: no binding for nonlocal 'x' found

From SF bug #1705365
>>> nonlocal x # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> nonlocal x
Traceback (most recent call last):
...
SyntaxError: nonlocal declaration not allowed at module level
Expand Down Expand Up @@ -1351,7 +1351,7 @@

Custom error messages for try blocks that are not followed by except/finally

>>> try: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> try:
... x = 34
...
Traceback (most recent call last):
Expand Down Expand Up @@ -1705,14 +1705,14 @@
Check that an multiple exception types with missing parentheses
raise a custom exception only when using 'as'

>>> try: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> try:
... pass
... except A, B, C as blech:
... pass
Traceback (most recent call last):
SyntaxError: multiple exception types must be parenthesized when using 'as'

>>> try: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> try:
... pass
... except A, B, C as blech:
... pass
Expand All @@ -1722,14 +1722,14 @@
SyntaxError: multiple exception types must be parenthesized when using 'as'


>>> try: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> try:
... pass
... except* A, B, C as blech:
... pass
Traceback (most recent call last):
SyntaxError: multiple exception types must be parenthesized when using 'as'

>>> try: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> try:
... pass
... except* A, B, C as blech:
... pass
Expand Down Expand Up @@ -1880,7 +1880,7 @@
Traceback (most recent call last):
SyntaxError: invalid syntax. Did you mean 'in'?

>>> f(a=23, a=234) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> f(a=23, a=234)
Traceback (most recent call last):
...
SyntaxError: keyword argument repeated: a
Expand Down Expand Up @@ -2001,11 +2001,11 @@
Traceback (most recent call last):
SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?

>>> from t import x, # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> from t import x,
Traceback (most recent call last):
SyntaxError: trailing comma not allowed without surrounding parentheses

>>> from t import x,y, # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> from t import x,y,
Traceback (most recent call last):
SyntaxError: trailing comma not allowed without surrounding parentheses

Expand Down Expand Up @@ -2164,31 +2164,31 @@

# 'not' after operators:

>>> 3 + not 3 # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> 3 + not 3
Traceback (most recent call last):
SyntaxError: 'not' after an operator must be parenthesized

>>> 3 * not 3 # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> 3 * not 3
Traceback (most recent call last):
SyntaxError: 'not' after an operator must be parenthesized

>>> + not 3 # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> + not 3
Traceback (most recent call last):
SyntaxError: 'not' after an operator must be parenthesized

>>> - not 3 # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> - not 3
Traceback (most recent call last):
SyntaxError: 'not' after an operator must be parenthesized

>>> ~ not 3 # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> ~ not 3
Traceback (most recent call last):
SyntaxError: 'not' after an operator must be parenthesized

>>> 3 + - not 3 # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> 3 + - not 3
Traceback (most recent call last):
SyntaxError: 'not' after an operator must be parenthesized

>>> 3 + not -1 # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> 3 + not -1
Traceback (most recent call last):
SyntaxError: 'not' after an operator must be parenthesized

Expand Down Expand Up @@ -2660,7 +2660,7 @@ def f(x: *b)
...
SyntaxError: yield expression cannot be used within the definition of a generic

>>> f(**x, *y) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
>>> f(**x, *y)
Traceback (most recent call last):
SyntaxError: iterable argument unpacking follows keyword argument unpacking

Expand Down Expand Up @@ -2936,24 +2936,20 @@ def test_bad_outdent(self):
"unindent does not match .* level",
subclass=IndentationError)

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

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

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

@unittest.expectedFailure # TODO: RUSTPYTHON
def test_generator_in_function_call(self):
self._check_error("foo(x, y for y in range(3) for z in range(2) if z , p)",
"Generator expression must be parenthesized",
Expand Down Expand Up @@ -3126,7 +3122,6 @@ def test_invalid_line_continuation_error_position(self):
"unexpected character after line continuation character",
lineno=3, offset=4)

@unittest.expectedFailure # TODO: RUSTPYTHON
def test_invalid_line_continuation_left_recursive(self):
# Check bpo-42218: SyntaxErrors following left-recursive rules
# (t_primary_raw in this case) need to be tested explicitly
Expand Down Expand Up @@ -3198,7 +3193,6 @@ def case(x):
"""
compile(code, "<string>", "exec")

@unittest.expectedFailure # TODO: RUSTPYTHON
def test_multiline_compiler_error_points_to_the_end(self):
self._check_error(
"call(\na=1,\na=1\n)",
Expand Down
2 changes: 1 addition & 1 deletion crates/codegen/src/symboltable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2941,7 +2941,7 @@ impl SymbolTableBuilder {
match role {
SymbolUsage::Nonlocal if scope_depth < 2 => {
return Err(SymbolTableError {
error: format!("cannot define nonlocal '{name}' at top level."),
error: "nonlocal declaration not allowed at module level".into(),
location,
});
}
Expand Down
Loading
Loading