398398
399399From ast_for_arguments():
400400
401- >>> def f(x, y=1, z): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
401+ >>> def f(x, y=1, z):
402402... pass
403403Traceback (most recent call last):
404404SyntaxError: parameter without a default follows parameter with a default
405405
406- >>> def f(x, /, y=1, z): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
406+ >>> def f(x, /, y=1, z):
407407... pass
408408Traceback (most recent call last):
409409SyntaxError: parameter without a default follows parameter with a default
423423Traceback (most recent call last):
424424SyntaxError: invalid syntax
425425
426- >>> def foo(/,a,b=,c): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
426+ >>> def foo(/,a,b=,c):
427427... pass
428428Traceback (most recent call last):
429429SyntaxError: at least one argument must precede /
430430
431- >>> def foo(a,/,/,b,c): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
431+ >>> def foo(a,/,/,b,c):
432432... pass
433433Traceback (most recent call last):
434434SyntaxError: / may appear only once
435435
436- >>> def foo(a,/,a1,/,b,c): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
436+ >>> def foo(a,/,a1,/,b,c):
437437... pass
438438Traceback (most recent call last):
439439SyntaxError: / may appear only once
440440
441- >>> def foo(a=1,/,/,*b,/,c): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
441+ >>> def foo(a=1,/,/,*b,/,c):
442442... pass
443443Traceback (most recent call last):
444444SyntaxError: / may appear only once
445445
446- >>> def foo(a,/,a1=1,/,b,c): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
446+ >>> def foo(a,/,a1=1,/,b,c):
447447... pass
448448Traceback (most recent call last):
449449SyntaxError: / may appear only once
450450
451- >>> def foo(a,*b,c,/,d,e): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
451+ >>> def foo(a,*b,c,/,d,e):
452452... pass
453453Traceback (most recent call last):
454454SyntaxError: / must be ahead of *
455455
456- >>> def foo(a=1,*b,c=3,/,d,e): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
456+ >>> def foo(a=1,*b,c=3,/,d,e):
457457... pass
458458Traceback (most recent call last):
459459SyntaxError: / must be ahead of *
460460
461- >>> def foo(a,*b=3,c): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
461+ >>> def foo(a,*b=3,c):
462462... pass
463463Traceback (most recent call last):
464464SyntaxError: var-positional argument cannot have default value
465465
466- >>> def foo(a,*b: int=,c): # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
466+ >>> def foo(a,*b: int=,c):
467467... pass
468468Traceback (most recent call last):
469469SyntaxError: var-positional argument cannot have default value
543543Traceback (most recent call last):
544544SyntaxError: expected default value expression
545545
546- >>> lambda /,a,b,c: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
546+ >>> lambda /,a,b,c: None
547547Traceback (most recent call last):
548548SyntaxError: at least one argument must precede /
549549
550- >>> lambda a,/,/,b,c: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
550+ >>> lambda a,/,/,b,c: None
551551Traceback (most recent call last):
552552SyntaxError: / may appear only once
553553
554- >>> lambda a,/,a1,/,b,c: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
554+ >>> lambda a,/,a1,/,b,c: None
555555Traceback (most recent call last):
556556SyntaxError: / may appear only once
557557
558- >>> lambda a=1,/,/,*b,/,c: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
558+ >>> lambda a=1,/,/,*b,/,c: None
559559Traceback (most recent call last):
560560SyntaxError: / may appear only once
561561
562- >>> lambda a,/,a1=1,/,b,c: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
562+ >>> lambda a,/,a1=1,/,b,c: None
563563Traceback (most recent call last):
564564SyntaxError: / may appear only once
565565
566- >>> lambda a,*b,c,/,d,e: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
566+ >>> lambda a,*b,c,/,d,e: None
567567Traceback (most recent call last):
568568SyntaxError: / must be ahead of *
569569
570- >>> lambda a=1,*b,c=3,/,d,e: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
570+ >>> lambda a=1,*b,c=3,/,d,e: None
571571Traceback (most recent call last):
572572SyntaxError: / must be ahead of *
573573
574574>>> lambda a=1,/*,b,c: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
575575Traceback (most recent call last):
576576SyntaxError: expected comma between / and *
577577
578- >>> lambda a,*b=3,c: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
578+ >>> lambda a,*b=3,c: None
579579Traceback (most recent call last):
580580SyntaxError: var-positional argument cannot have default value
581581
627627Traceback (most recent call last):
628628SyntaxError: expected default value expression
629629
630- >>> lambda a,d=3,c: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
630+ >>> lambda a,d=3,c: None
631631Traceback (most recent call last):
632632SyntaxError: parameter without a default follows parameter with a default
633633
634- >>> lambda a,/,d=3,c: None # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
634+ >>> lambda a,/,d=3,c: None
635635Traceback (most recent call last):
636636SyntaxError: parameter without a default follows parameter with a default
637637
661661>>> L = range(10)
662662>>> f(x for x in L)
663663[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
664- >>> f(x for x in L, 1) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
664+ >>> f(x for x in L, 1)
665665Traceback (most recent call last):
666666SyntaxError: Generator expression must be parenthesized
667- >>> f(x for x in L, y=1) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
667+ >>> f(x for x in L, y=1)
668668Traceback (most recent call last):
669669SyntaxError: Generator expression must be parenthesized
670- >>> f(x for x in L, *[]) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
670+ >>> f(x for x in L, *[])
671671Traceback (most recent call last):
672672SyntaxError: Generator expression must be parenthesized
673- >>> f(x for x in L, **{}) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
673+ >>> f(x for x in L, **{})
674674Traceback (most recent call last):
675675SyntaxError: Generator expression must be parenthesized
676- >>> f(L, x for x in L) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
676+ >>> f(L, x for x in L)
677677Traceback (most recent call last):
678678SyntaxError: Generator expression must be parenthesized
679- >>> f(x for x in L, y for y in L) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
679+ >>> f(x for x in L, y for y in L)
680680Traceback (most recent call last):
681681SyntaxError: Generator expression must be parenthesized
682- >>> f(x for x in L,) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
682+ >>> f(x for x in L,)
683683Traceback (most recent call last):
684684SyntaxError: Generator expression must be parenthesized
685685>>> f((x for x in L), 1)
10271027 SyntaxError: no binding for nonlocal 'x' found
10281028
10291029From 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
13511351
13521352Custom 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):
17051705Check that an multiple exception types with missing parentheses
17061706raise a custom exception only when using 'as'
17071707
1708- >>> try: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1708+ >>> try:
17091709 ... pass
17101710 ... except A, B, C as blech:
17111711 ... pass
17121712 Traceback (most recent call last):
17131713 SyntaxError: multiple exception types must be parenthesized when using 'as'
17141714
1715- >>> try: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1715+ >>> try:
17161716 ... pass
17171717 ... except A, B, C as blech:
17181718 ... pass
17221722 SyntaxError: multiple exception types must be parenthesized when using 'as'
17231723
17241724
1725- >>> try: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1725+ >>> try:
17261726 ... pass
17271727 ... except* A, B, C as blech:
17281728 ... pass
17291729 Traceback (most recent call last):
17301730 SyntaxError: multiple exception types must be parenthesized when using 'as'
17311731
1732- >>> try: # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1732+ >>> try:
17331733 ... pass
17341734 ... except* A, B, C as blech:
17351735 ... pass
18801880Traceback (most recent call last):
18811881SyntaxError: invalid syntax. Did you mean 'in'?
18821882
1883- >>> f(a=23, a=234) # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
1883+ >>> f(a=23, a=234)
18841884Traceback (most recent call last):
18851885 ...
18861886SyntaxError: keyword argument repeated: a
20012001Traceback (most recent call last):
20022002SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?
20032003
2004- >>> from t import x, # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
2004+ >>> from t import x,
20052005Traceback (most recent call last):
20062006SyntaxError: trailing comma not allowed without surrounding parentheses
20072007
2008- >>> from t import x,y, # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
2008+ >>> from t import x,y,
20092009Traceback (most recent call last):
20102010SyntaxError: trailing comma not allowed without surrounding parentheses
20112011
21642164
21652165# 'not' after operators:
21662166
2167- >>> 3 + not 3 # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
2167+ >>> 3 + not 3
21682168Traceback (most recent call last):
21692169SyntaxError: 'not' after an operator must be parenthesized
21702170
2171- >>> 3 * not 3 # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
2171+ >>> 3 * not 3
21722172Traceback (most recent call last):
21732173SyntaxError: 'not' after an operator must be parenthesized
21742174
2175- >>> + not 3 # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
2175+ >>> + not 3
21762176Traceback (most recent call last):
21772177SyntaxError: 'not' after an operator must be parenthesized
21782178
2179- >>> - not 3 # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
2179+ >>> - not 3
21802180Traceback (most recent call last):
21812181SyntaxError: 'not' after an operator must be parenthesized
21822182
2183- >>> ~ not 3 # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
2183+ >>> ~ not 3
21842184Traceback (most recent call last):
21852185SyntaxError: 'not' after an operator must be parenthesized
21862186
2187- >>> 3 + - not 3 # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
2187+ >>> 3 + - not 3
21882188Traceback (most recent call last):
21892189SyntaxError: 'not' after an operator must be parenthesized
21902190
2191- >>> 3 + not -1 # TODO: RUSTPYTHON; Wrong error message # doctest: +EXPECTED_FAILURE
2191+ >>> 3 + not -1
21922192Traceback (most recent call last):
21932193SyntaxError: 'not' after an operator must be parenthesized
21942194
@@ -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,24 +2936,20 @@ 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 "
29542951 "keyword argument unpacking" )
29552952
2956- @unittest .expectedFailure # TODO: RUSTPYTHON
29572953 def test_generator_in_function_call (self ):
29582954 self ._check_error ("foo(x, y for y in range(3) for z in range(2) if z , p)" ,
29592955 "Generator expression must be parenthesized" ,
@@ -3126,7 +3122,6 @@ def test_invalid_line_continuation_error_position(self):
31263122 "unexpected character after line continuation character" ,
31273123 lineno = 3 , offset = 4 )
31283124
3129- @unittest .expectedFailure # TODO: RUSTPYTHON
31303125 def test_invalid_line_continuation_left_recursive (self ):
31313126 # Check bpo-42218: SyntaxErrors following left-recursive rules
31323127 # (t_primary_raw in this case) need to be tested explicitly
@@ -3198,7 +3193,6 @@ def case(x):
31983193"""
31993194 compile (code , "<string>" , "exec" )
32003195
3201- @unittest .expectedFailure # TODO: RUSTPYTHON
32023196 def test_multiline_compiler_error_points_to_the_end (self ):
32033197 self ._check_error (
32043198 "call(\n a=1,\n a=1\n )" ,
0 commit comments