403Webshell
Server IP : 121.121.20.254  /  Your IP : 216.73.216.202
Web Server : Microsoft-IIS/10.0
System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64
User : IUSR ( 0)
PHP Version : 8.3.28
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/Python315/Lib/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/Python315/Lib/test/__pycache__/test_syntax.cpython-315.pyc
R
>lqj�c���Qs]PHs]PHs]PHs]PHs]QHGsQQ\O2sQQ\O2s	QQ\	2s
Qs\Q	6Xc\O2P!P!)
u�;This module tests SyntaxErrors.

Here's an example of the sort of thing that is tested.

>>> def f(x):
...     global x
Traceback (most recent call last):
SyntaxError: name 'x' is parameter and global

The tests are all raise SyntaxErrors.  They were created by checking
each C call that raises SyntaxError.  There are several modules that
raise these exceptions-- ast.c, compile.c, future.c, pythonrun.c, and
symtable.c.

The parser itself outlaws a lot of invalid syntax.  None of these
errors are tested here at the moment.  We should add some tests; since
there are infinitely many programs with invalid syntax, we would need
to be judicious in selecting some.

The compiler generates a synthetic module name for code executed by
doctest.  Since all the code comes from the same module, a suffix like
[1] is appended to the module name, As a consequence, changing the
order of tests in this module means renumbering all the errors after
it.  (Maybe we should enable the ellipsis option for these tests.)

In ast.c, syntax errors are raised by calling ast_error().

Errors from set_context():

>>> obj.None = 1
Traceback (most recent call last):
SyntaxError: invalid syntax

>>> None = 1
Traceback (most recent call last):
SyntaxError: cannot assign to None

>>> obj.True = 1
Traceback (most recent call last):
SyntaxError: invalid syntax

>>> True = 1
Traceback (most recent call last):
SyntaxError: cannot assign to True

>>> (True := 1)
Traceback (most recent call last):
SyntaxError: cannot use assignment expressions with True

>>> obj.__debug__ = 1
Traceback (most recent call last):
SyntaxError: cannot assign to __debug__

>>> __debug__ = 1
Traceback (most recent call last):
SyntaxError: cannot assign to __debug__

>>> (__debug__ := 1)
Traceback (most recent call last):
SyntaxError: cannot assign to __debug__

>>> def __debug__(): pass
Traceback (most recent call last):
SyntaxError: cannot assign to __debug__

>>> async def __debug__(): pass
Traceback (most recent call last):
SyntaxError: cannot assign to __debug__

>>> class __debug__: pass
Traceback (most recent call last):
SyntaxError: cannot assign to __debug__

>>> del __debug__
Traceback (most recent call last):
SyntaxError: cannot delete __debug__

>>> f() = 1
Traceback (most recent call last):
SyntaxError: cannot assign to function call here. Maybe you meant '==' instead of '='?

>>> yield = 1
Traceback (most recent call last):
SyntaxError: assignment to yield expression not possible

>>> del f()
Traceback (most recent call last):
SyntaxError: cannot delete function call

>>> a + 1 = 2
Traceback (most recent call last):
SyntaxError: cannot assign to expression here. Maybe you meant '==' instead of '='?

>>> (x for x in x) = 1
Traceback (most recent call last):
SyntaxError: cannot assign to generator expression

>>> 1 = 1
Traceback (most recent call last):
SyntaxError: cannot assign to literal here. Maybe you meant '==' instead of '='?

>>> "abc" = 1
Traceback (most recent call last):
SyntaxError: cannot assign to literal here. Maybe you meant '==' instead of '='?

>>> b"" = 1
Traceback (most recent call last):
SyntaxError: cannot assign to literal here. Maybe you meant '==' instead of '='?

>>> ... = 1
Traceback (most recent call last):
SyntaxError: cannot assign to ellipsis here. Maybe you meant '==' instead of '='?

>>> `1` = 1
Traceback (most recent call last):
SyntaxError: invalid syntax

If the left-hand side of an assignment is a list or tuple, an illegal
expression inside that contain should still cause a syntax error.
This test just checks a couple of cases rather than enumerating all of
them.

>>> (a, "b", c) = (1, 2, 3)
Traceback (most recent call last):
SyntaxError: cannot assign to literal

>>> (a, True, c) = (1, 2, 3)
Traceback (most recent call last):
SyntaxError: cannot assign to True

>>> (a, __debug__, c) = (1, 2, 3)
Traceback (most recent call last):
SyntaxError: cannot assign to __debug__

>>> (a, *True, c) = (1, 2, 3)
Traceback (most recent call last):
SyntaxError: cannot assign to True

>>> (a, *__debug__, c) = (1, 2, 3)
Traceback (most recent call last):
SyntaxError: cannot assign to __debug__

>>> [a, b, c + 1] = [1, 2, 3]
Traceback (most recent call last):
SyntaxError: cannot assign to expression

>>> [a, b[1], c + 1] = [1, 2, 3]
Traceback (most recent call last):
SyntaxError: cannot assign to expression

>>> [a, b.c.d, c + 1] = [1, 2, 3]
Traceback (most recent call last):
SyntaxError: cannot assign to expression

>>> a if 1 else b = 1
Traceback (most recent call last):
SyntaxError: cannot assign to conditional expression

>>> a = 42 if True
Traceback (most recent call last):
SyntaxError: expected 'else' after 'if' expression

>>> a = (42 if True)
Traceback (most recent call last):
SyntaxError: expected 'else' after 'if' expression

>>> a = [1, 42 if True, 4]
Traceback (most recent call last):
SyntaxError: expected 'else' after 'if' expression

>>> x = 1 if 1 else pass
Traceback (most recent call last):
SyntaxError: expected expression after 'else', but statement is given

>>> x = pass if 1 else 1
Traceback (most recent call last):
SyntaxError: expected expression before 'if', but statement is given

>>> x = pass if 1 else pass
Traceback (most recent call last):
SyntaxError: expected expression before 'if', but statement is given

>>> if True:
...     print("Hello"
...
... if 2:
...    print(123))
Traceback (most recent call last):
SyntaxError: invalid syntax

>>> True = True = 3
Traceback (most recent call last):
SyntaxError: cannot assign to True

>>> x = y = True = z = 3
Traceback (most recent call last):
SyntaxError: cannot assign to True

>>> x = y = yield = 1
Traceback (most recent call last):
SyntaxError: assignment to yield expression not possible

>>> a, b += 1, 2
Traceback (most recent call last):
SyntaxError: 'tuple' is an illegal expression for augmented assignment

>>> (a, b) += 1, 2
Traceback (most recent call last):
SyntaxError: 'tuple' is an illegal expression for augmented assignment

>>> [a, b] += 1, 2
Traceback (most recent call last):
SyntaxError: 'list' is an illegal expression for augmented assignment

Invalid targets in `for` loops and `with` statements should also
produce a specialized error message

>>> for a() in b: pass
Traceback (most recent call last):
SyntaxError: cannot assign to function call

>>> for (a, b()) in b: pass
Traceback (most recent call last):
SyntaxError: cannot assign to function call

>>> for [a, b()] in b: pass
Traceback (most recent call last):
SyntaxError: cannot assign to function call

>>> for (*a, b, c+1) in b: pass
Traceback (most recent call last):
SyntaxError: cannot assign to expression

>>> for (x, *(y, z.d())) in b: pass
Traceback (most recent call last):
SyntaxError: cannot assign to function call

>>> for a, b() in c: pass
Traceback (most recent call last):
SyntaxError: cannot assign to function call

>>> for a, b, (c + 1, d()): pass
Traceback (most recent call last):
SyntaxError: cannot assign to expression

>>> for i < (): pass
Traceback (most recent call last):
SyntaxError: invalid syntax

>>> for a, b
Traceback (most recent call last):
SyntaxError: invalid syntax

>>> with a as b(): pass
Traceback (most recent call last):
SyntaxError: cannot assign to function call

>>> with a as (b, c()): pass
Traceback (most recent call last):
SyntaxError: cannot assign to function call

>>> with a as [b, c()]: pass
Traceback (most recent call last):
SyntaxError: cannot assign to function call

>>> with a as (*b, c, d+1): pass
Traceback (most recent call last):
SyntaxError: cannot assign to expression

>>> with a as (x, *(y, z.d())): pass
Traceback (most recent call last):
SyntaxError: cannot assign to function call

>>> with a as b, c as d(): pass
Traceback (most recent call last):
SyntaxError: cannot assign to function call

>>> with a as b
Traceback (most recent call last):
SyntaxError: expected ':'

>>> p = p =
Traceback (most recent call last):
SyntaxError: invalid syntax

Comprehensions without 'in' keyword:

>>> [x for x if range(1)]
Traceback (most recent call last):
SyntaxError: 'in' expected after for-loop variables

>>> tuple(x for x if range(1))
Traceback (most recent call last):
SyntaxError: 'in' expected after for-loop variables

>>> [x for x() in a]
Traceback (most recent call last):
SyntaxError: cannot assign to function call

>>> [x for a, b, (c + 1, d()) in y]
Traceback (most recent call last):
SyntaxError: cannot assign to expression

>>> [x for a, b, (c + 1, d()) if y]
Traceback (most recent call last):
SyntaxError: 'in' expected after for-loop variables

>>> [x for x+1 in y]
Traceback (most recent call last):
SyntaxError: cannot assign to expression

>>> [x for x+1, x() in y]
Traceback (most recent call last):
SyntaxError: cannot assign to expression

Comprehensions creating tuples without parentheses
should produce a specialized error message:

>>> [x,y for x,y in range(100)]
Traceback (most recent call last):
SyntaxError: did you forget parentheses around the comprehension target?

>>> {x,y for x,y in range(100)}
Traceback (most recent call last):
SyntaxError: did you forget parentheses around the comprehension target?

# Incorrectly closed strings

>>> "The interesting object "The important object" is very important"
Traceback (most recent call last):
SyntaxError: invalid syntax. Is this intended to be part of the string?

# Missing commas in literals collections should not
# produce special error messages regarding missing
# parentheses, but about missing commas instead

>>> [1, 2 3]
Traceback (most recent call last):
SyntaxError: invalid syntax. Perhaps you forgot a comma?

>>> {1, 2 3}
Traceback (most recent call last):
SyntaxError: invalid syntax. Perhaps you forgot a comma?

>>> {1:2, 2:5 3:12}
Traceback (most recent call last):
SyntaxError: invalid syntax. Perhaps you forgot a comma?

>>> (1, 2 3)
Traceback (most recent call last):
SyntaxError: invalid syntax. Perhaps you forgot a comma?

# Make sure soft keywords constructs don't raise specialized
# errors regarding missing commas or other spezialiced errors

>>> match x:
...     y = 3
Traceback (most recent call last):
SyntaxError: invalid syntax

>>> match x:
...     case y:
...        3 $ 3
Traceback (most recent call last):
SyntaxError: invalid syntax

>>> match x:
...     case $:
...        ...
Traceback (most recent call last):
SyntaxError: invalid syntax

>>> match ...:
...     case {**_}:
...        ...
Traceback (most recent call last):
SyntaxError: invalid syntax

# Check incorrect "case" placement with specialized error messages

>>> case "pattern": ...
Traceback (most recent call last):
SyntaxError: case statement must be inside match statement

>>> case 1 | 2: ...
Traceback (most recent call last):
SyntaxError: case statement must be inside match statement

>>> case klass(attr=1) | {}: ...
Traceback (most recent call last):
SyntaxError: case statement must be inside match statement

>>> case [] if x > 1: ...
Traceback (most recent call last):
SyntaxError: case statement must be inside match statement

>>> case match: ...
Traceback (most recent call last):
SyntaxError: case statement must be inside match statement

>>> case case: ...
Traceback (most recent call last):
SyntaxError: case statement must be inside match statement

>>> if some:
...     case 1: ...
Traceback (most recent call last):
SyntaxError: case statement must be inside match statement

>>> case some:
...     case 1: ...
Traceback (most recent call last):
SyntaxError: case statement must be inside match statement

# But prefixes of soft keywords should
# still raise specialized errors

>>> (mat x)
Traceback (most recent call last):
SyntaxError: invalid syntax. Perhaps you forgot a comma?

From compiler_complex_args():

>>> def f(None=1):
...     pass
Traceback (most recent call last):
SyntaxError: invalid syntax

From ast_for_arguments():

>>> 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):
...     pass
Traceback (most recent call last):
SyntaxError: parameter without a default follows parameter with a default

>>> def f(x, None):
...     pass
Traceback (most recent call last):
SyntaxError: invalid syntax

>>> def f(*None):
...     pass
Traceback (most recent call last):
SyntaxError: invalid syntax

>>> def f(**None):
...     pass
Traceback (most recent call last):
SyntaxError: invalid syntax

>>> def foo(/,a,b=,c):
...    pass
Traceback (most recent call last):
SyntaxError: at least one parameter must precede /

>>> def foo(a,/,/,b,c):
...    pass
Traceback (most recent call last):
SyntaxError: / may appear only once

>>> def foo(a,/,a1,/,b,c):
...    pass
Traceback (most recent call last):
SyntaxError: / may appear only once

>>> def foo(a=1,/,/,*b,/,c):
...    pass
Traceback (most recent call last):
SyntaxError: / may appear only once

>>> 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):
...    pass
Traceback (most recent call last):
SyntaxError: / must be ahead of *

>>> 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):
...    pass
Traceback (most recent call last):
SyntaxError: var-positional parameter cannot have default value

>>> def foo(a,*b: int=,c):
...    pass
Traceback (most recent call last):
SyntaxError: var-positional parameter cannot have default value

>>> def foo(a,**b=3):
...    pass
Traceback (most recent call last):
SyntaxError: var-keyword parameter cannot have default value

>>> def foo(a,**b: int=3):
...    pass
Traceback (most recent call last):
SyntaxError: var-keyword parameter cannot have default value

>>> def foo(a,*a, b, **c, d):
...    pass
Traceback (most recent call last):
SyntaxError: parameters cannot follow var-keyword parameter

>>> def foo(a,*a, b, **c, d=4):
...    pass
Traceback (most recent call last):
SyntaxError: parameters cannot follow var-keyword parameter

>>> def foo(a,*a, b, **c, *d):
...    pass
Traceback (most recent call last):
SyntaxError: parameters cannot follow var-keyword parameter

>>> def foo(a,*a, b, **c, **d):
...    pass
Traceback (most recent call last):
SyntaxError: parameters cannot follow var-keyword parameter

>>> def foo(a=1,/,**b,/,c):
...    pass
Traceback (most recent call last):
SyntaxError: parameters cannot follow var-keyword parameter

>>> def foo(*b,*d):
...    pass
Traceback (most recent call last):
SyntaxError: * may appear only once

>>> def foo(a,*b,c,*d,*e,c):
...    pass
Traceback (most recent call last):
SyntaxError: * may appear only once

>>> def foo(a,b,/,c,*b,c,*d,*e,c):
...    pass
Traceback (most recent call last):
SyntaxError: * may appear only once

>>> def foo(a,b,/,c,*b,c,*d,**e):
...    pass
Traceback (most recent call last):
SyntaxError: * may appear only once

>>> def foo(a=1,/*,b,c):
...    pass
Traceback (most recent call last):
SyntaxError: expected comma between / and *

>>> def foo(a=1,d=,c):
...    pass
Traceback (most recent call last):
SyntaxError: expected default value expression

>>> def foo(a,d=,c):
...    pass
Traceback (most recent call last):
SyntaxError: expected default value expression

>>> def foo(a,d: int=,c):
...    pass
Traceback (most recent call last):
SyntaxError: expected default value expression

>>> lambda /,a,b,c: None
Traceback (most recent call last):
SyntaxError: at least one parameter must precede /

>>> lambda a,/,/,b,c: None
Traceback (most recent call last):
SyntaxError: / may appear only once

>>> lambda a,/,a1,/,b,c: None
Traceback (most recent call last):
SyntaxError: / may appear only once

>>> lambda a=1,/,/,*b,/,c: None
Traceback (most recent call last):
SyntaxError: / may appear only once

>>> lambda a,/,a1=1,/,b,c: None
Traceback (most recent call last):
SyntaxError: / may appear only once

>>> 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
Traceback (most recent call last):
SyntaxError: / must be ahead of *

>>> lambda a=1,/*,b,c: None
Traceback (most recent call last):
SyntaxError: expected comma between / and *

>>> lambda a,*b=3,c: None
Traceback (most recent call last):
SyntaxError: var-positional parameter cannot have default value

>>> lambda a,**b=3: None
Traceback (most recent call last):
SyntaxError: var-keyword parameter cannot have default value

>>> lambda a, *a, b, **c, d: None
Traceback (most recent call last):
SyntaxError: parameters cannot follow var-keyword parameter

>>> lambda a,*a, b, **c, d=4: None
Traceback (most recent call last):
SyntaxError: parameters cannot follow var-keyword parameter

>>> lambda a,*a, b, **c, *d: None
Traceback (most recent call last):
SyntaxError: parameters cannot follow var-keyword parameter

>>> lambda a,*a, b, **c, **d: None
Traceback (most recent call last):
SyntaxError: parameters cannot follow var-keyword parameter

>>> lambda a=1,/,**b,/,c: None
Traceback (most recent call last):
SyntaxError: parameters cannot follow var-keyword parameter

>>> lambda *b,*d: None
Traceback (most recent call last):
SyntaxError: * may appear only once

>>> lambda a,*b,c,*d,*e,c: None
Traceback (most recent call last):
SyntaxError: * may appear only once

>>> lambda a,b,/,c,*b,c,*d,*e,c: None
Traceback (most recent call last):
SyntaxError: * may appear only once

>>> lambda a,b,/,c,*b,c,*d,**e: None
Traceback (most recent call last):
SyntaxError: * may appear only once

>>> lambda a=1,d=,c: None
Traceback (most recent call last):
SyntaxError: expected default value expression

>>> lambda a,d=,c: None
Traceback (most recent call last):
SyntaxError: expected default value expression

>>> 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
Traceback (most recent call last):
SyntaxError: parameter without a default follows parameter with a default

>>> import ast; ast.parse('''
... def f(
...     *, # type: int
...     a, # type: int
... ):
...     pass
... ''', type_comments=True)
Traceback (most recent call last):
SyntaxError: bare * has associated type comment


From ast_for_funcdef():

>>> def None(x):
...     pass
Traceback (most recent call last):
SyntaxError: invalid syntax


From ast_for_call():

>>> def f(it, *varargs, **kwargs):
...     return list(it)
>>> 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)
Traceback (most recent call last):
SyntaxError: Generator expression must be parenthesized
>>> 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, *[])
Traceback (most recent call last):
SyntaxError: Generator expression must be parenthesized
>>> f(x for x in L, **{})
Traceback (most recent call last):
SyntaxError: Generator expression must be parenthesized
>>> 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)
Traceback (most recent call last):
SyntaxError: Generator expression must be parenthesized
>>> f(x for x in L,)
Traceback (most recent call last):
SyntaxError: Generator expression must be parenthesized
>>> f((x for x in L), 1)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> class C(x for x in L):
...     pass
Traceback (most recent call last):
SyntaxError: invalid syntax

>>> def g(*args, **kwargs):
...     print(args, sorted(kwargs.items()))
>>> g(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
...   20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
...   38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
...   56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
...   74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
...   92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
...   108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
...   122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
...   136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
...   150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163,
...   164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
...   178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
...   192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205,
...   206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
...   220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233,
...   234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247,
...   248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261,
...   262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275,
...   276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289,
...   290, 291, 292, 293, 294, 295, 296, 297, 298, 299)  # doctest: +ELLIPSIS
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ..., 297, 298, 299) []

>>> g(a000=0, a001=1, a002=2, a003=3, a004=4, a005=5, a006=6, a007=7, a008=8,
...   a009=9, a010=10, a011=11, a012=12, a013=13, a014=14, a015=15, a016=16,
...   a017=17, a018=18, a019=19, a020=20, a021=21, a022=22, a023=23, a024=24,
...   a025=25, a026=26, a027=27, a028=28, a029=29, a030=30, a031=31, a032=32,
...   a033=33, a034=34, a035=35, a036=36, a037=37, a038=38, a039=39, a040=40,
...   a041=41, a042=42, a043=43, a044=44, a045=45, a046=46, a047=47, a048=48,
...   a049=49, a050=50, a051=51, a052=52, a053=53, a054=54, a055=55, a056=56,
...   a057=57, a058=58, a059=59, a060=60, a061=61, a062=62, a063=63, a064=64,
...   a065=65, a066=66, a067=67, a068=68, a069=69, a070=70, a071=71, a072=72,
...   a073=73, a074=74, a075=75, a076=76, a077=77, a078=78, a079=79, a080=80,
...   a081=81, a082=82, a083=83, a084=84, a085=85, a086=86, a087=87, a088=88,
...   a089=89, a090=90, a091=91, a092=92, a093=93, a094=94, a095=95, a096=96,
...   a097=97, a098=98, a099=99, a100=100, a101=101, a102=102, a103=103,
...   a104=104, a105=105, a106=106, a107=107, a108=108, a109=109, a110=110,
...   a111=111, a112=112, a113=113, a114=114, a115=115, a116=116, a117=117,
...   a118=118, a119=119, a120=120, a121=121, a122=122, a123=123, a124=124,
...   a125=125, a126=126, a127=127, a128=128, a129=129, a130=130, a131=131,
...   a132=132, a133=133, a134=134, a135=135, a136=136, a137=137, a138=138,
...   a139=139, a140=140, a141=141, a142=142, a143=143, a144=144, a145=145,
...   a146=146, a147=147, a148=148, a149=149, a150=150, a151=151, a152=152,
...   a153=153, a154=154, a155=155, a156=156, a157=157, a158=158, a159=159,
...   a160=160, a161=161, a162=162, a163=163, a164=164, a165=165, a166=166,
...   a167=167, a168=168, a169=169, a170=170, a171=171, a172=172, a173=173,
...   a174=174, a175=175, a176=176, a177=177, a178=178, a179=179, a180=180,
...   a181=181, a182=182, a183=183, a184=184, a185=185, a186=186, a187=187,
...   a188=188, a189=189, a190=190, a191=191, a192=192, a193=193, a194=194,
...   a195=195, a196=196, a197=197, a198=198, a199=199, a200=200, a201=201,
...   a202=202, a203=203, a204=204, a205=205, a206=206, a207=207, a208=208,
...   a209=209, a210=210, a211=211, a212=212, a213=213, a214=214, a215=215,
...   a216=216, a217=217, a218=218, a219=219, a220=220, a221=221, a222=222,
...   a223=223, a224=224, a225=225, a226=226, a227=227, a228=228, a229=229,
...   a230=230, a231=231, a232=232, a233=233, a234=234, a235=235, a236=236,
...   a237=237, a238=238, a239=239, a240=240, a241=241, a242=242, a243=243,
...   a244=244, a245=245, a246=246, a247=247, a248=248, a249=249, a250=250,
...   a251=251, a252=252, a253=253, a254=254, a255=255, a256=256, a257=257,
...   a258=258, a259=259, a260=260, a261=261, a262=262, a263=263, a264=264,
...   a265=265, a266=266, a267=267, a268=268, a269=269, a270=270, a271=271,
...   a272=272, a273=273, a274=274, a275=275, a276=276, a277=277, a278=278,
...   a279=279, a280=280, a281=281, a282=282, a283=283, a284=284, a285=285,
...   a286=286, a287=287, a288=288, a289=289, a290=290, a291=291, a292=292,
...   a293=293, a294=294, a295=295, a296=296, a297=297, a298=298, a299=299)
...  # doctest: +ELLIPSIS
() [('a000', 0), ('a001', 1), ('a002', 2), ..., ('a298', 298), ('a299', 299)]

>>> class C:
...     def meth(self, *args):
...         return args
>>> obj = C()
>>> obj.meth(
...   0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
...   20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
...   38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
...   56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
...   74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
...   92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
...   108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
...   122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
...   136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
...   150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163,
...   164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
...   178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
...   192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205,
...   206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
...   220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233,
...   234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247,
...   248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261,
...   262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275,
...   276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289,
...   290, 291, 292, 293, 294, 295, 296, 297, 298, 299)  # doctest: +ELLIPSIS
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ..., 297, 298, 299)

>>> f(lambda x: x[0] = 3)
Traceback (most recent call last):
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?

# Check that this error doesn't trigger for names:
>>> f(a={x: for x in {}})
Traceback (most recent call last):
SyntaxError: invalid syntax

The grammar accepts any test (basically, any expression) in the
keyword slot of a call site.  Test a few different options.

>>> f(x()=2)
Traceback (most recent call last):
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
>>> f(a or b=1)
Traceback (most recent call last):
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
>>> f(x.y=1)
Traceback (most recent call last):
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
>>> f((x)=2)
Traceback (most recent call last):
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
>>> f(True=1)
Traceback (most recent call last):
SyntaxError: cannot assign to True
>>> f(False=1)
Traceback (most recent call last):
SyntaxError: cannot assign to False
>>> f(None=1)
Traceback (most recent call last):
SyntaxError: cannot assign to None
>>> f(__debug__=1)
Traceback (most recent call last):
SyntaxError: cannot assign to __debug__
>>> __debug__: int
Traceback (most recent call last):
SyntaxError: cannot assign to __debug__
>>> x.__debug__: int
Traceback (most recent call last):
SyntaxError: cannot assign to __debug__
>>> f(a=)
Traceback (most recent call last):
SyntaxError: expected argument value expression
>>> f(a, b, c=)
Traceback (most recent call last):
SyntaxError: expected argument value expression
>>> f(a, b, c=, d)
Traceback (most recent call last):
SyntaxError: expected argument value expression
>>> f(*args=[0])
Traceback (most recent call last):
SyntaxError: cannot assign to iterable argument unpacking
>>> f(a, b, *args=[0])
Traceback (most recent call last):
SyntaxError: cannot assign to iterable argument unpacking
>>> f(**kwargs={'a': 1})
Traceback (most recent call last):
SyntaxError: cannot assign to keyword argument unpacking
>>> f(a, b, *args, **kwargs={'a': 1})
Traceback (most recent call last):
SyntaxError: cannot assign to keyword argument unpacking


More set_context():

>>> (x for x in x) += 1
Traceback (most recent call last):
SyntaxError: 'generator expression' is an illegal expression for augmented assignment
>>> None += 1
Traceback (most recent call last):
SyntaxError: 'None' is an illegal expression for augmented assignment
>>> __debug__ += 1
Traceback (most recent call last):
SyntaxError: cannot assign to __debug__
>>> f() += 1
Traceback (most recent call last):
SyntaxError: 'function call' is an illegal expression for augmented assignment


Test control flow in finally

continue in for loop under finally should be ok.

    >>> def test():
    ...     try:
    ...         pass
    ...     finally:
    ...         for abc in range(10):
    ...             continue
    ...     print(abc)
    >>> test()
    9

break in for loop under finally should be ok.

    >>> def test():
    ...     try:
    ...         pass
    ...     finally:
    ...         for abc in range(10):
    ...             break
    ...     print(abc)
    >>> test()
    0

return in function under finally should be ok.

    >>> def test():
    ...     try:
    ...         pass
    ...     finally:
    ...         def f():
    ...             return 42
    ...     print(f())
    >>> test()
    42

combine for loop and function def

return in function under finally should be ok.

    >>> def test():
    ...     try:
    ...         pass
    ...     finally:
    ...         for i in range(10):
    ...             def f():
    ...                 return 42
    ...     print(f())
    >>> test()
    42

    >>> def test():
    ...     try:
    ...         pass
    ...     finally:
    ...         def f():
    ...             for i in range(10):
    ...                 return 42
    ...     print(f())
    >>> test()
    42

A continue outside loop should not be allowed.

    >>> def foo():
    ...     try:
    ...         continue
    ...     finally:
    ...         pass
    Traceback (most recent call last):
      ...
    SyntaxError: 'continue' not properly in loop

There is one test for a break that is not in a loop.  The compiler
uses a single data structure to keep track of try-finally and loops,
so we need to be sure that a break is actually inside a loop.  If it
isn't, there should be a syntax error.

   >>> try:
   ...     print(1)
   ...     break
   ...     print(2)
   ... finally:
   ...     print(3)
   Traceback (most recent call last):
     ...
   SyntaxError: 'break' outside loop

elif can't come after an else.

    >>> if a % 2 == 0:
    ...     pass
    ... else:
    ...     pass
    ... elif a % 2 == 1:
    ...     pass
    Traceback (most recent call last):
      ...
    SyntaxError: 'elif' block follows an 'else' block

Misuse of the nonlocal and global statement can lead to a few unique syntax errors.

   >>> def f():
   ...     print(x)
   ...     global x
   Traceback (most recent call last):
     ...
   SyntaxError: name 'x' is used prior to global declaration

   >>> def f():
   ...     x = 1
   ...     global x
   Traceback (most recent call last):
     ...
   SyntaxError: name 'x' is assigned to before global declaration

   >>> def f(x):
   ...     global x
   Traceback (most recent call last):
     ...
   SyntaxError: name 'x' is parameter and global

   >>> def f():
   ...     x = 1
   ...     def g():
   ...         print(x)
   ...         nonlocal x
   Traceback (most recent call last):
     ...
   SyntaxError: name 'x' is used prior to nonlocal declaration

   >>> def f():
   ...     x = 1
   ...     def g():
   ...         x = 2
   ...         nonlocal x
   Traceback (most recent call last):
     ...
   SyntaxError: name 'x' is assigned to before nonlocal declaration

   >>> def f(x):
   ...     nonlocal x
   Traceback (most recent call last):
     ...
   SyntaxError: name 'x' is parameter and nonlocal

   >>> def f():
   ...     global x
   ...     nonlocal x
   Traceback (most recent call last):
     ...
   SyntaxError: name 'x' is nonlocal and global

   >>> def f():
   ...     nonlocal x
   Traceback (most recent call last):
     ...
   SyntaxError: no binding for nonlocal 'x' found

From SF bug #1705365
   >>> nonlocal x
   Traceback (most recent call last):
     ...
   SyntaxError: nonlocal declaration not allowed at module level

From https://bugs.python.org/issue25973
   >>> class A:
   ...     def f(self):
   ...         nonlocal __x
   Traceback (most recent call last):
     ...
   SyntaxError: no binding for nonlocal '_A__x' found


This tests assignment-context; there was a bug in Python 2.5 where compiling
a complex 'if' (one with 'elif') would fail to notice an invalid suite,
leading to spurious errors.

   >>> if 1:
   ...   x() = 1
   ... elif 1:
   ...   pass
   Traceback (most recent call last):
     ...
   SyntaxError: cannot assign to function call here. Maybe you meant '==' instead of '='?

   >>> if 1:
   ...   pass
   ... elif 1:
   ...   x() = 1
   Traceback (most recent call last):
     ...
   SyntaxError: cannot assign to function call here. Maybe you meant '==' instead of '='?

   >>> if 1:
   ...   x() = 1
   ... elif 1:
   ...   pass
   ... else:
   ...   pass
   Traceback (most recent call last):
     ...
   SyntaxError: cannot assign to function call here. Maybe you meant '==' instead of '='?

   >>> if 1:
   ...   pass
   ... elif 1:
   ...   x() = 1
   ... else:
   ...   pass
   Traceback (most recent call last):
     ...
   SyntaxError: cannot assign to function call here. Maybe you meant '==' instead of '='?

   >>> if 1:
   ...   pass
   ... elif 1:
   ...   pass
   ... else:
   ...   x() = 1
   Traceback (most recent call last):
     ...
   SyntaxError: cannot assign to function call here. Maybe you meant '==' instead of '='?

Missing ':' before suites:

   >>> def f()
   ...     pass
   Traceback (most recent call last):
   SyntaxError: expected ':'

   >>> def f[T]()
   ...     pass
   Traceback (most recent call last):
   SyntaxError: expected ':'

   >>> class A
   ...     pass
   Traceback (most recent call last):
   SyntaxError: expected ':'

   >>> class A[T]
   ...     pass
   Traceback (most recent call last):
   SyntaxError: expected ':'

   >>> class A[T]()
   ...     pass
   Traceback (most recent call last):
   SyntaxError: expected ':'

   >>> class R&D:
   ...     pass
   Traceback (most recent call last):
   SyntaxError: invalid syntax

   >>> if 1
   ...   pass
   ... elif 1:
   ...   pass
   ... else:
   ...   x() = 1
   Traceback (most recent call last):
   SyntaxError: expected ':'

   >>> if 1:
   ...   pass
   ... elif 1
   ...   pass
   ... else:
   ...   x() = 1
   Traceback (most recent call last):
   SyntaxError: expected ':'

   >>> if 1:
   ...   pass
   ... elif 1:
   ...   pass
   ... else
   ...   x() = 1
   Traceback (most recent call last):
   SyntaxError: expected ':'

   >>> for x in range(10)
   ...   pass
   Traceback (most recent call last):
   SyntaxError: expected ':'

   >>> for x in range 10:
   ...   pass
   Traceback (most recent call last):
   SyntaxError: invalid syntax

   >>> while True
   ...   pass
   Traceback (most recent call last):
   SyntaxError: expected ':'

   >>> with blech as something
   ...   pass
   Traceback (most recent call last):
   SyntaxError: expected ':'

   >>> with blech
   ...   pass
   Traceback (most recent call last):
   SyntaxError: expected ':'

   >>> with blech, block as something
   ...   pass
   Traceback (most recent call last):
   SyntaxError: expected ':'

   >>> with blech, block as something, bluch
   ...   pass
   Traceback (most recent call last):
   SyntaxError: expected ':'

   >>> with (blech as something)
   ...   pass
   Traceback (most recent call last):
   SyntaxError: expected ':'

   >>> with (blech)
   ...   pass
   Traceback (most recent call last):
   SyntaxError: expected ':'

   >>> with (blech, block as something)
   ...   pass
   Traceback (most recent call last):
   SyntaxError: expected ':'

   >>> with (blech, block as something, bluch)
   ...   pass
   Traceback (most recent call last):
   SyntaxError: expected ':'

   >>> with block ad something:
   ...   pass
   Traceback (most recent call last):
   SyntaxError: invalid syntax. Did you mean 'and'?

   >>> try
   ...   pass
   Traceback (most recent call last):
   SyntaxError: expected ':'

   >>> try:
   ...   pass
   ... except
   ...   pass
   Traceback (most recent call last):
   SyntaxError: expected ':'

   >>> match x
   ...   case list():
   ...       pass
   Traceback (most recent call last):
   SyntaxError: expected ':'

   >>> match x x:
   ...   case list():
   ...       pass
   Traceback (most recent call last):
   SyntaxError: invalid syntax

   >>> match x:
   ...   case list()
   ...       pass
   Traceback (most recent call last):
   SyntaxError: expected ':'

   >>> match x:
   ...   case [y] if y > 0
   ...       pass
   Traceback (most recent call last):
   SyntaxError: expected ':'

   >>> match x:
   ...   case a, __debug__, b:
   ...       pass
   Traceback (most recent call last):
   SyntaxError: cannot assign to __debug__

   >>> match x:
   ...   case a, b, *__debug__:
   ...       pass
   Traceback (most recent call last):
   SyntaxError: cannot assign to __debug__

   >>> match x:
   ...   case Foo(a, __debug__=1, b=2):
   ...       pass
   Traceback (most recent call last):
   SyntaxError: cannot assign to __debug__

   >>> if x = 3:
   ...    pass
   Traceback (most recent call last):
   SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?

   >>> while x = 3:
   ...    pass
   Traceback (most recent call last):
   SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?

   >>> if x.a = 3:
   ...    pass
   Traceback (most recent call last):
   SyntaxError: cannot assign to attribute here. Maybe you meant '==' instead of '='?

   >>> while x.a = 3:
   ...    pass
   Traceback (most recent call last):
   SyntaxError: cannot assign to attribute here. Maybe you meant '==' instead of '='?


Missing parens after function definition

   >>> def f:
   Traceback (most recent call last):
   SyntaxError: expected '('

   >>> async def f:
   Traceback (most recent call last):
   SyntaxError: expected '('

   >>> def f -> int:
   Traceback (most recent call last):
   SyntaxError: expected '('

   >>> async def f -> int:  # type: int
   Traceback (most recent call last):
   SyntaxError: expected '('

   >>> async def f[T]:
   Traceback (most recent call last):
   SyntaxError: expected '('

   >>> def f[T] -> str:
   Traceback (most recent call last):
   SyntaxError: expected '('

Parenthesized parameters in function definitions

   >>> def f(x, (y, z), w):
   ...    pass
   Traceback (most recent call last):
   SyntaxError: Function parameters cannot be parenthesized

   >>> def f((x, y, z, w)):
   ...    pass
   Traceback (most recent call last):
   SyntaxError: Function parameters cannot be parenthesized

   >>> def f(x, (y, z, w)):
   ...    pass
   Traceback (most recent call last):
   SyntaxError: Function parameters cannot be parenthesized

   >>> def f((x, y, z), w):
   ...    pass
   Traceback (most recent call last):
   SyntaxError: Function parameters cannot be parenthesized

   >>> lambda x, (y, z), w: None
   Traceback (most recent call last):
   SyntaxError: Lambda expression parameters cannot be parenthesized

   >>> lambda (x, y, z, w): None
   Traceback (most recent call last):
   SyntaxError: Lambda expression parameters cannot be parenthesized

   >>> lambda x, (y, z, w): None
   Traceback (most recent call last):
   SyntaxError: Lambda expression parameters cannot be parenthesized

   >>> lambda (x, y, z), w: None
   Traceback (most recent call last):
   SyntaxError: Lambda expression parameters cannot be parenthesized

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

   >>> try:
   ...    x = 34
   ...
   Traceback (most recent call last):
   SyntaxError: expected 'except' or 'finally' block

Custom error message for __debug__ as exception variable

   >>> try:
   ...    pass
   ... except TypeError as __debug__:
   ...    pass
   Traceback (most recent call last):
   SyntaxError: cannot assign to __debug__

Custom error message for try block mixing except and except*

   >>> try:
   ...    pass
   ... except TypeError:
   ...    pass
   ... except* ValueError:
   ...    pass
   Traceback (most recent call last):
   SyntaxError: cannot have both 'except' and 'except*' on the same 'try'

   >>> try:
   ...    pass
   ... except* TypeError:
   ...    pass
   ... except ValueError:
   ...    pass
   Traceback (most recent call last):
   SyntaxError: cannot have both 'except' and 'except*' on the same 'try'

   >>> try:
   ...    pass
   ... except TypeError:
   ...    pass
   ... except TypeError:
   ...    pass
   ... except* ValueError:
   ...    pass
   Traceback (most recent call last):
   SyntaxError: cannot have both 'except' and 'except*' on the same 'try'

   >>> try:
   ...    pass
   ... except* TypeError:
   ...    pass
   ... except* TypeError:
   ...    pass
   ... except ValueError:
   ...    pass
   Traceback (most recent call last):
   SyntaxError: cannot have both 'except' and 'except*' on the same 'try'

Better error message for using `except as` with not a name:

   >>> try:
   ...    pass
   ... except TypeError as obj.attr:
   ...    pass
   Traceback (most recent call last):
   SyntaxError: cannot use except statement with attribute

   >>> try:
   ...    pass
   ... except TypeError as obj[1]:
   ...    pass
   Traceback (most recent call last):
   SyntaxError: cannot use except statement with subscript

   >>> try:
   ...    pass
   ... except* TypeError as (obj, name):
   ...    pass
   Traceback (most recent call last):
   SyntaxError: cannot use except* statement with tuple

   >>> try:
   ...    pass
   ... except* TypeError as 1:
   ...    pass
   Traceback (most recent call last):
   SyntaxError: cannot use except* statement with literal

Regression tests for gh-133999:

   >>> try: pass
   ... except TypeError as name: raise from None
   Traceback (most recent call last):
   SyntaxError: did you forget an expression between 'raise' and 'from'?

   >>> try: pass
   ... except* TypeError as name: raise from None
   Traceback (most recent call last):
   SyntaxError: did you forget an expression between 'raise' and 'from'?

   >>> match 1:
   ...     case 1 | 2 as abc: raise from None
   Traceback (most recent call last):
   SyntaxError: did you forget an expression between 'raise' and 'from'?

Ensure that early = are not matched by the parser as invalid comparisons
   >>> f(2, 4, x=34); 1 $ 2
   Traceback (most recent call last):
   SyntaxError: invalid syntax

   >>> dict(x=34); x $ y
   Traceback (most recent call last):
   SyntaxError: invalid syntax

   >>> dict(x=34, (x for x in range 10), 1); x $ y
   Traceback (most recent call last):
   SyntaxError: invalid syntax

   >>> dict(x=34, x=1, y=2); x $ y
   Traceback (most recent call last):
   SyntaxError: invalid syntax

Incomplete dictionary literals

   >>> {1:2, 3:4, 5}
   Traceback (most recent call last):
   SyntaxError: ':' expected after dictionary key

   >>> {1:2, 3:4, 5:}
   Traceback (most recent call last):
   SyntaxError: expression expected after dictionary key and ':'

   >>> {1: *12+1, 23: 1}
   Traceback (most recent call last):
   SyntaxError: cannot use a starred expression in a dictionary value

   >>> {1: *12+1}
   Traceback (most recent call last):
   SyntaxError: cannot use a starred expression in a dictionary value

   >>> {1: 23, 1: *12+1}
   Traceback (most recent call last):
   SyntaxError: cannot use a starred expression in a dictionary value

   >>> {1:}
   Traceback (most recent call last):
   SyntaxError: expression expected after dictionary key and ':'

   # Ensure that the error is not raised for syntax errors that happen after sets

   >>> {1} $
   Traceback (most recent call last):
   SyntaxError: invalid syntax

   # Ensure that the error is not raised for invalid expressions

   >>> {1: 2, 3: foo(,), 4: 5}
   Traceback (most recent call last):
   SyntaxError: invalid syntax

   >>> {1: $, 2: 3}
   Traceback (most recent call last):
   SyntaxError: invalid syntax

Specialized indentation errors:

   >>> while condition:
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after 'while' statement on line 1

   >>> for x in range(10):
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after 'for' statement on line 1

   >>> for x in range(10):
   ...     pass
   ... else:
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after 'else' statement on line 3

   >>> async for x in range(10):
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after 'for' statement on line 1

   >>> async for x in range(10):
   ...     pass
   ... else:
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after 'else' statement on line 3

   >>> if something:
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after 'if' statement on line 1

   >>> if something:
   ...     pass
   ... elif something_else:
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after 'elif' statement on line 3

   >>> if something:
   ...     pass
   ... elif something_else:
   ...     pass
   ... else:
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after 'else' statement on line 5

   >>> try:
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after 'try' statement on line 1

   >>> try:
   ...     something()
   ... except:
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after 'except' statement on line 3

   >>> try:
   ...     something()
   ... except A:
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after 'except' statement on line 3

   >>> try:
   ...     something()
   ... except* A:
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after 'except*' statement on line 3

   >>> try:
   ...     something()
   ... except A:
   ...     pass
   ... finally:
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after 'finally' statement on line 5

   >>> try:
   ...     something()
   ... except* A:
   ...     pass
   ... finally:
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after 'finally' statement on line 5

   >>> with A:
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after 'with' statement on line 1

   >>> with A as a, B as b:
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after 'with' statement on line 1

   >>> with (A as a, B as b):
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after 'with' statement on line 1

   >>> async with A:
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after 'with' statement on line 1

   >>> async with A as a, B as b:
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after 'with' statement on line 1

   >>> async with (A as a, B as b):
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after 'with' statement on line 1

   >>> def foo(x, /, y, *, z=2):
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after function definition on line 1

   >>> def foo[T](x, /, y, *, z=2):
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after function definition on line 1

   >>> class Blech(A):
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after class definition on line 1

   >>> class Blech[T](A):
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after class definition on line 1

   >>> class C(__debug__=42): ...
   Traceback (most recent call last):
   SyntaxError: cannot assign to __debug__

   >>> class Meta(type):
   ...     def __new__(*args, **kwargs):
   ...         pass

   >>> class C(metaclass=Meta, __debug__=42):
   ...     pass
   Traceback (most recent call last):
   SyntaxError: cannot assign to __debug__

   >>> match something:
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after 'match' statement on line 1

   >>> match something:
   ...     case []:
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after 'case' statement on line 2

   >>> match something:
   ...     case []:
   ...         ...
   ...     case {}:
   ... pass
   Traceback (most recent call last):
   IndentationError: expected an indented block after 'case' statement on line 4

Make sure that the old "raise X, Y[, Z]" form is gone:
   >>> raise X, Y
   Traceback (most recent call last):
     ...
   SyntaxError: invalid syntax
   >>> raise X, Y, Z
   Traceback (most recent call last):
     ...
   SyntaxError: invalid syntax

Better errors for `raise` statement:

    >>> raise ValueError from
    Traceback (most recent call last):
    SyntaxError: did you forget an expression after 'from'?

    >>> raise mod.ValueError() from
    Traceback (most recent call last):
    SyntaxError: did you forget an expression after 'from'?

    >>> raise from exc
    Traceback (most recent call last):
    SyntaxError: did you forget an expression between 'raise' and 'from'?

    >>> raise from None
    Traceback (most recent call last):
    SyntaxError: did you forget an expression between 'raise' and 'from'?

    >>> raise from
    Traceback (most recent call last):
    SyntaxError: did you forget an expression between 'raise' and 'from'?

Check that an multiple exception types with missing parentheses
raise a custom exception only when using 'as'

   >>> 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:
   ...   pass
   ... except A, B, C as blech:
   ...   pass
   ... finally:
   ...   pass
   Traceback (most recent call last):
   SyntaxError: multiple exception types must be parenthesized when using 'as'


   >>> 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:
   ...   pass
   ... except* A, B, C as blech:
   ...   pass
   ... finally:
   ...   pass
   Traceback (most recent call last):
   SyntaxError: multiple exception types must be parenthesized when using 'as'

Custom exception for 'except*' without an exception type

   >>> try:
   ...   pass
   ... except* A as a:
   ...   pass
   ... except*:
   ...   pass
   Traceback (most recent call last):
   SyntaxError: expected one or more exception types

Check custom exceptions for keywords with typos

>>> fur a in b:
...   pass
Traceback (most recent call last):
SyntaxError: invalid syntax. Did you mean 'for'?

>>> for a in b:
...   pass
... elso:
...   pass
Traceback (most recent call last):
SyntaxError: invalid syntax. Did you mean 'else'?

>>> whille True:
...   pass
Traceback (most recent call last):
SyntaxError: invalid syntax. Did you mean 'while'?

>>> while True:
...   pass
... elso:
...   pass
Traceback (most recent call last):
SyntaxError: invalid syntax. Did you mean 'else'?

>>> iff x > 5:
...   pass
Traceback (most recent call last):
SyntaxError: invalid syntax. Did you mean 'if'?

>>> if x:
...   pass
... elseif y:
...   pass
Traceback (most recent call last):
SyntaxError: invalid syntax. Did you mean 'elif'?

>>> if x:
...   pass
... elif y:
...   pass
... elso:
...   pass
Traceback (most recent call last):
SyntaxError: invalid syntax. Did you mean 'else'?

>>> tyo:
...   pass
... except y:
...   pass
Traceback (most recent call last):
SyntaxError: invalid syntax. Did you mean 'try'?

>>> classe MyClass:
...   pass
Traceback (most recent call last):
SyntaxError: invalid syntax. Did you mean 'class'?

>>> impor math
Traceback (most recent call last):
SyntaxError: invalid syntax. Did you mean 'import'?

>>> form x import y
Traceback (most recent call last):
SyntaxError: invalid syntax. Did you mean 'from'?

>>> defn calculate_sum(a, b):
...   return a + b
Traceback (most recent call last):
SyntaxError: invalid syntax. Did you mean 'def'?

>>> def foo():
...   returm result
Traceback (most recent call last):
SyntaxError: invalid syntax. Did you mean 'return'?

>>> lamda x: x ** 2
Traceback (most recent call last):
SyntaxError: invalid syntax. Did you mean 'lambda'?

>>> def foo():
...   yeld i
Traceback (most recent call last):
SyntaxError: invalid syntax. Did you mean 'yield'?

>>> def foo():
...   globel counter
Traceback (most recent call last):
SyntaxError: invalid syntax. Did you mean 'global'?

>>> frum math import sqrt
Traceback (most recent call last):
SyntaxError: invalid syntax. Did you mean 'from'?

>>> asynch def fetch_data():
...   pass
Traceback (most recent call last):
SyntaxError: invalid syntax. Did you mean 'async'?

>>> async def foo():
...   awaid fetch_data()
Traceback (most recent call last):
SyntaxError: invalid syntax. Did you mean 'await'?

>>> raisee ValueError("Error")
Traceback (most recent call last):
SyntaxError: invalid syntax. Did you mean 'raise'?

>>> [
... x for x
... in range(3)
... of x
... ]
Traceback (most recent call last):
SyntaxError: invalid syntax. Did you mean 'if'?

>>> [
... 123 fur x
... in range(3)
... if x
... ]
Traceback (most recent call last):
SyntaxError: invalid syntax. Did you mean 'for'?


>>> for x im n:
...     pass
Traceback (most recent call last):
SyntaxError: invalid syntax. Did you mean 'in'?

>>> f(a=23, a=234)
Traceback (most recent call last):
   ...
SyntaxError: keyword argument repeated: a

>>> {1, 2, 3} = 42
Traceback (most recent call last):
SyntaxError: cannot assign to set display here. Maybe you meant '==' instead of '='?

>>> {1: 2, 3: 4} = 42
Traceback (most recent call last):
SyntaxError: cannot assign to dict literal here. Maybe you meant '==' instead of '='?

>>> f'{x}' = 42
Traceback (most recent call last):
SyntaxError: cannot assign to f-string expression here. Maybe you meant '==' instead of '='?

>>> f'{x}-{y}' = 42
Traceback (most recent call last):
SyntaxError: cannot assign to f-string expression here. Maybe you meant '==' instead of '='?

>>> ub''
Traceback (most recent call last):
SyntaxError: 'u' and 'b' prefixes are incompatible

>>> bu"привет"
Traceback (most recent call last):
SyntaxError: 'u' and 'b' prefixes are incompatible

>>> ur''
Traceback (most recent call last):
SyntaxError: 'u' and 'r' prefixes are incompatible

>>> ru" "
Traceback (most recent call last):
SyntaxError: 'u' and 'r' prefixes are incompatible

>>> uf'{1 + 1}'
Traceback (most recent call last):
SyntaxError: 'u' and 'f' prefixes are incompatible

>>> fu""
Traceback (most recent call last):
SyntaxError: 'u' and 'f' prefixes are incompatible

>>> ut'{1}'
Traceback (most recent call last):
SyntaxError: 'u' and 't' prefixes are incompatible

>>> tu"234"
Traceback (most recent call last):
SyntaxError: 'u' and 't' prefixes are incompatible

>>> bf'{x!r}'
Traceback (most recent call last):
SyntaxError: 'b' and 'f' prefixes are incompatible

>>> fb"text"
Traceback (most recent call last):
SyntaxError: 'b' and 'f' prefixes are incompatible

>>> bt"text"
Traceback (most recent call last):
SyntaxError: 'b' and 't' prefixes are incompatible

>>> tb''
Traceback (most recent call last):
SyntaxError: 'b' and 't' prefixes are incompatible

>>> tf"{0.3:.02f}"
Traceback (most recent call last):
SyntaxError: 'f' and 't' prefixes are incompatible

>>> ft'{x=}'
Traceback (most recent call last):
SyntaxError: 'f' and 't' prefixes are incompatible

>>> tfu"{x=}"
Traceback (most recent call last):
SyntaxError: 'u' and 'f' prefixes are incompatible

>>> turf"{x=}"
Traceback (most recent call last):
SyntaxError: 'u' and 'r' prefixes are incompatible

>>> burft"{x=}"
Traceback (most recent call last):
SyntaxError: 'u' and 'b' prefixes are incompatible

>>> brft"{x=}"
Traceback (most recent call last):
SyntaxError: 'b' and 'f' prefixes are incompatible

>>> t'{x}' = 42
Traceback (most recent call last):
SyntaxError: cannot assign to t-string expression here. Maybe you meant '==' instead of '='?

>>> t'{x}-{y}' = 42
Traceback (most recent call last):
SyntaxError: cannot assign to t-string expression here. Maybe you meant '==' instead of '='?

>>> (x, y, z=3, d, e)
Traceback (most recent call last):
SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?

>>> [x, y, z=3, d, e]
Traceback (most recent call last):
SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?

>>> [z=3]
Traceback (most recent call last):
SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?

>>> {x, y, z=3, d, e}
Traceback (most recent call last):
SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?

>>> {z=3}
Traceback (most recent call last):
SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?

>>> from t import x,
Traceback (most recent call last):
SyntaxError: trailing comma not allowed without surrounding parentheses

>>> from t import x,y,
Traceback (most recent call last):
SyntaxError: trailing comma not allowed without surrounding parentheses

>>> with item,: pass
Traceback (most recent call last):
SyntaxError: the last 'with' item has a trailing comma

>>> with item as x,: pass
Traceback (most recent call last):
SyntaxError: the last 'with' item has a trailing comma

>>> with item1, item2,: pass
Traceback (most recent call last):
SyntaxError: the last 'with' item has a trailing comma

>>> with item1 as x, item2,: pass
Traceback (most recent call last):
SyntaxError: the last 'with' item has a trailing comma

>>> with item1 as x, item2 as y,: pass
Traceback (most recent call last):
SyntaxError: the last 'with' item has a trailing comma

>>> with item1, item2 as y,: pass
Traceback (most recent call last):
SyntaxError: the last 'with' item has a trailing comma

>>> import a from b
Traceback (most recent call last):
SyntaxError: Did you mean to use 'from ... import ...' instead?

>>> import a.y.z from b.y.z
Traceback (most recent call last):
SyntaxError: Did you mean to use 'from ... import ...' instead?

>>> import a from b as bar
Traceback (most recent call last):
SyntaxError: Did you mean to use 'from ... import ...' instead?

>>> import a.y.z from b.y.z as bar
Traceback (most recent call last):
SyntaxError: Did you mean to use 'from ... import ...' instead?

>>> import a, b,c from b
Traceback (most recent call last):
SyntaxError: Did you mean to use 'from ... import ...' instead?

>>> import a.y.z, b.y.z, c.y.z from b.y.z
Traceback (most recent call last):
SyntaxError: Did you mean to use 'from ... import ...' instead?

>>> import a,b,c from b as bar
Traceback (most recent call last):
SyntaxError: Did you mean to use 'from ... import ...' instead?

>>> import a.y.z, b.y.z, c.y.z from b.y.z as bar
Traceback (most recent call last):
SyntaxError: Did you mean to use 'from ... import ...' instead?

>>> import __debug__
Traceback (most recent call last):
SyntaxError: cannot assign to __debug__

>>> import a as __debug__
Traceback (most recent call last):
SyntaxError: cannot assign to __debug__

>>> import a.b.c as __debug__
Traceback (most recent call last):
SyntaxError: cannot assign to __debug__

>>> from a import __debug__
Traceback (most recent call last):
SyntaxError: cannot assign to __debug__

>>> from a import b as __debug__
Traceback (most recent call last):
SyntaxError: cannot assign to __debug__

>>> import a as b.c
Traceback (most recent call last):
SyntaxError: cannot use attribute as import target

>>> import a.b as (a, b)
Traceback (most recent call last):
SyntaxError: cannot use tuple as import target

>>> import a, a.b as 1
Traceback (most recent call last):
SyntaxError: cannot use literal as import target

>>> import a.b as 'a', a
Traceback (most recent call last):
SyntaxError: cannot use literal as import target

>>> from a import (b as c.d)
Traceback (most recent call last):
SyntaxError: cannot use attribute as import target

>>> from a import b as 1
Traceback (most recent call last):
SyntaxError: cannot use literal as import target

>>> from a import (
...   b as f())
Traceback (most recent call last):
SyntaxError: cannot use function call as import target

>>> from a import (
...   b as [],
... )
Traceback (most recent call last):
SyntaxError: cannot use list as import target

>>> from a import (
...   b,
...   c as ()
... )
Traceback (most recent call last):
SyntaxError: cannot use tuple as import target

>>> from a import b, с as d[e]
Traceback (most recent call last):
SyntaxError: cannot use subscript as import target

>>> from a import с as d[e], b
Traceback (most recent call last):
SyntaxError: cannot use subscript as import target

# Check that we don't raise a "cannot use name as import target" error
# if there is an error in an unrelated statement after ';'

>>> import a as b; None = 1
Traceback (most recent call last):
SyntaxError: cannot assign to None

>>> import a, b as c; d = 1; None = 1
Traceback (most recent call last):
SyntaxError: cannot assign to None

>>> from a import b as c; None = 1
Traceback (most recent call last):
SyntaxError: cannot assign to None

>>> from a import b, c as d; e = 1; None = 1
Traceback (most recent call last):
SyntaxError: cannot assign to None

# Check that we dont raise the "trailing comma" error if there is more
# input to the left of the valid part that we parsed.

>>> from t import x,y, and 3
Traceback (most recent call last):
SyntaxError: invalid syntax

>>> from i import
Traceback (most recent call last):
SyntaxError: Expected one or more names after 'import'

>>> from .. import
Traceback (most recent call last):
SyntaxError: Expected one or more names after 'import'

>>> import
Traceback (most recent call last):
SyntaxError: Expected one or more names after 'import'

>>> (): int
Traceback (most recent call last):
SyntaxError: only single target (not tuple) can be annotated
>>> []: int
Traceback (most recent call last):
SyntaxError: only single target (not list) can be annotated
>>> (()): int
Traceback (most recent call last):
SyntaxError: only single target (not tuple) can be annotated
>>> ([]): int
Traceback (most recent call last):
SyntaxError: only single target (not list) can be annotated

>>> 1: int
Traceback (most recent call last):
SyntaxError: illegal target for annotation
>>> -x: int = 1
Traceback (most recent call last):
SyntaxError: illegal target for annotation
>>> (x for x in y): int
Traceback (most recent call last):
SyntaxError: illegal target for annotation

# 'not' after operators:

>>> 3 + not 3
Traceback (most recent call last):
SyntaxError: 'not' after an operator must be parenthesized

>>> 3 * not 3
Traceback (most recent call last):
SyntaxError: 'not' after an operator must be parenthesized

>>> + not 3
Traceback (most recent call last):
SyntaxError: 'not' after an operator must be parenthesized

>>> - not 3
Traceback (most recent call last):
SyntaxError: 'not' after an operator must be parenthesized

>>> ~ not 3
Traceback (most recent call last):
SyntaxError: 'not' after an operator must be parenthesized

>>> 3 + - not 3
Traceback (most recent call last):
SyntaxError: 'not' after an operator must be parenthesized

>>> 3 + not -1
Traceback (most recent call last):
SyntaxError: 'not' after an operator must be parenthesized

# Check that we don't introduce misleading errors
>>> not 1 */ 2
Traceback (most recent call last):
SyntaxError: invalid syntax

>>> not 1 +
Traceback (most recent call last):
SyntaxError: invalid syntax

>>> not + 1 +
Traceback (most recent call last):
SyntaxError: invalid syntax

Corner-cases that used to fail to raise the correct error:

    >>> def f(*, x=lambda __debug__:0): pass
    Traceback (most recent call last):
    SyntaxError: cannot assign to __debug__

    >>> def f(*args:(lambda __debug__:0)): pass
    Traceback (most recent call last):
    SyntaxError: cannot assign to __debug__

    >>> def f(**kwargs:(lambda __debug__:0)): pass
    Traceback (most recent call last):
    SyntaxError: cannot assign to __debug__

    >>> with (lambda *:0): pass
    Traceback (most recent call last):
    SyntaxError: named parameters must follow bare *

Corner-cases that used to crash:

    >>> def f(**__debug__): pass
    Traceback (most recent call last):
    SyntaxError: cannot assign to __debug__

    >>> def f(*xx, __debug__): pass
    Traceback (most recent call last):
    SyntaxError: cannot assign to __debug__

    >>> import ä £
    Traceback (most recent call last):
    SyntaxError: invalid character '£' (U+00A3)

Invalid pattern matching constructs:

    >>> match ...:
    ...   case 42 as _:
    ...     ...
    Traceback (most recent call last):
    SyntaxError: cannot use '_' as a target

    >>> match ...:
    ...   case 42 as 1+2+4:
    ...     ...
    Traceback (most recent call last):
    SyntaxError: cannot use expression as pattern target

    >>> match ...:
    ...   case 42 as a.b:
    ...     ...
    Traceback (most recent call last):
    SyntaxError: cannot use attribute as pattern target

    >>> match ...:
    ...   case 42 as (a, b):
    ...     ...
    Traceback (most recent call last):
    SyntaxError: cannot use tuple as pattern target

    >>> match ...:
    ...   case 42 as (a + 1):
    ...     ...
    Traceback (most recent call last):
    SyntaxError: cannot use expression as pattern target

    >>> match ...:
    ...   case (32 as x) | (42 as a()):
    ...     ...
    Traceback (most recent call last):
    SyntaxError: cannot use function call as pattern target

    >>> match ...:
    ...   case Foo(z=1, y=2, x):
    ...     ...
    Traceback (most recent call last):
    SyntaxError: positional patterns follow keyword patterns

    >>> match ...:
    ...   case Foo(a, z=1, y=2, x):
    ...     ...
    Traceback (most recent call last):
    SyntaxError: positional patterns follow keyword patterns

    >>> match ...:
    ...   case Foo(z=1, x, y=2):
    ...     ...
    Traceback (most recent call last):
    SyntaxError: positional patterns follow keyword patterns

    >>> match ...:
    ...   case Foo(y=1, x=2, y=3):
    ...     ...
    Traceback (most recent call last):
    SyntaxError: attribute name repeated in class pattern: y

    >>> match ...:
    ...   case C(a=b, c, d=e, f, g=h, i, j=k, ...):
    ...     ...
    Traceback (most recent call last):
    SyntaxError: positional patterns follow keyword patterns

    >>> match ...:
    ...   case {**double_star, "spam": "eggs"}:
    ...     ...
    Traceback (most recent call last):
    SyntaxError: double star pattern must be the last (right-most) subpattern in the mapping pattern

    >>> match ...:
    ...   case {"foo": 1, **double_star, "spam": "eggs"}:
    ...     ...
    Traceback (most recent call last):
    SyntaxError: double star pattern must be the last (right-most) subpattern in the mapping pattern

    >>> match ...:
    ...   case {"spam": "eggs", "b": {**d, "ham": "bacon"}}:
    ...     ...
    Traceback (most recent call last):
    SyntaxError: double star pattern must be the last (right-most) subpattern in the mapping pattern

Uses of the star operator which should fail:

A[:*b]

    >>> A[:*b]
    Traceback (most recent call last):
        ...
    SyntaxError: invalid syntax
    >>> A[:(*b)]
    Traceback (most recent call last):
        ...
    SyntaxError: cannot use starred expression here
    >>> A[:*b] = 1
    Traceback (most recent call last):
        ...
    SyntaxError: invalid syntax
    >>> del A[:*b]
    Traceback (most recent call last):
        ...
    SyntaxError: invalid syntax

A[*b:]

    >>> A[*b:]
    Traceback (most recent call last):
        ...
    SyntaxError: invalid syntax
    >>> A[(*b):]
    Traceback (most recent call last):
        ...
    SyntaxError: cannot use starred expression here
    >>> A[*b:] = 1
    Traceback (most recent call last):
        ...
    SyntaxError: invalid syntax
    >>> del A[*b:]
    Traceback (most recent call last):
        ...
    SyntaxError: invalid syntax

A[*b:*b]

    >>> A[*b:*b]
    Traceback (most recent call last):
        ...
    SyntaxError: invalid syntax
    >>> A[(*b:*b)]
    Traceback (most recent call last):
        ...
    SyntaxError: invalid syntax
    >>> A[*b:*b] = 1
    Traceback (most recent call last):
        ...
    SyntaxError: invalid syntax
    >>> del A[*b:*b]
    Traceback (most recent call last):
        ...
    SyntaxError: invalid syntax

A[*(1:2)]

    >>> A[*(1:2)]
    Traceback (most recent call last):
        ...
    SyntaxError: Invalid star expression
    >>> A[*(1:2)] = 1
    Traceback (most recent call last):
        ...
    SyntaxError: Invalid star expression
    >>> del A[*(1:2)]
    Traceback (most recent call last):
        ...
    SyntaxError: Invalid star expression

A[*:] and A[:*]

    >>> A[*:]
    Traceback (most recent call last):
        ...
    SyntaxError: Invalid star expression
    >>> A[:*]
    Traceback (most recent call last):
        ...
    SyntaxError: invalid syntax

A[*]

    >>> A[*]
    Traceback (most recent call last):
        ...
    SyntaxError: Invalid star expression

A[**]

    >>> A[**]
    Traceback (most recent call last):
        ...
    SyntaxError: invalid syntax

A[**b]

    >>> A[**b]
    Traceback (most recent call last):
        ...
    SyntaxError: invalid syntax
    >>> A[**b] = 1
    Traceback (most recent call last):
        ...
    SyntaxError: invalid syntax
    >>> del A[**b]
    Traceback (most recent call last):
        ...
    SyntaxError: invalid syntax

def f(x: *b)

    >>> def f6(x: *b): pass
    Traceback (most recent call last):
        ...
    SyntaxError: invalid syntax
    >>> def f7(x: *b = 1): pass
    Traceback (most recent call last):
        ...
    SyntaxError: invalid syntax

**kwargs: *a

    >>> def f8(**kwargs: *a): pass
    Traceback (most recent call last):
        ...
    SyntaxError: invalid syntax

x: *b

    >>> x: *b
    Traceback (most recent call last):
        ...
    SyntaxError: invalid syntax
    >>> x: *b = 1
    Traceback (most recent call last):
        ...
    SyntaxError: invalid syntax

Invalid bytes literals:

   >>> b"Ā"
   Traceback (most recent call last):
      ...
       b"Ā"
        ^^^
   SyntaxError: bytes can only contain ASCII literal characters

   >>> b"абвгде"
   Traceback (most recent call last):
      ...
       b"абвгде"
        ^^^^^^^^
   SyntaxError: bytes can only contain ASCII literal characters

   >>> b"abc ъющый"  # first 3 letters are ascii
   Traceback (most recent call last):
      ...
       b"abc ъющый"
        ^^^^^^^^^^^
   SyntaxError: bytes can only contain ASCII literal characters

Invalid expressions in type scopes:

   >>> type A[] = int
   Traceback (most recent call last):
   ...
   SyntaxError: Type parameter list cannot be empty

   >>> class A[]: ...
   Traceback (most recent call last):
   ...
   SyntaxError: Type parameter list cannot be empty

   >>> def some[](): ...
   Traceback (most recent call last):
   ...
   SyntaxError: Type parameter list cannot be empty

   >>> def some[]()
   Traceback (most recent call last):
   ...
   SyntaxError: Type parameter list cannot be empty

   >>> async def some[]:  # type: int
   Traceback (most recent call last):
   ...
   SyntaxError: Type parameter list cannot be empty

   >>> def f[T: (x:=3)](): pass
   Traceback (most recent call last):
      ...
   SyntaxError: named expression cannot be used within a TypeVar bound

   >>> def f[T: ((x:= 3), int)](): pass
   Traceback (most recent call last):
      ...
   SyntaxError: named expression cannot be used within a TypeVar constraint

   >>> def f[T = ((x:=3))](): pass
   Traceback (most recent call last):
      ...
   SyntaxError: named expression cannot be used within a TypeVar default

   >>> async def f[T: (x:=3)](): pass
   Traceback (most recent call last):
      ...
   SyntaxError: named expression cannot be used within a TypeVar bound

   >>> async def f[T: ((x:= 3), int)](): pass
   Traceback (most recent call last):
      ...
   SyntaxError: named expression cannot be used within a TypeVar constraint

   >>> async def f[T = ((x:=3))](): pass
   Traceback (most recent call last):
      ...
   SyntaxError: named expression cannot be used within a TypeVar default

   >>> type A[T: (x:=3)] = int
   Traceback (most recent call last):
      ...
   SyntaxError: named expression cannot be used within a TypeVar bound

   >>> type A[T: ((x:= 3), int)] = int
   Traceback (most recent call last):
      ...
   SyntaxError: named expression cannot be used within a TypeVar constraint

   >>> type A[T = ((x:=3))] = int
   Traceback (most recent call last):
      ...
   SyntaxError: named expression cannot be used within a TypeVar default

   >>> def f[T: (yield)](): pass
   Traceback (most recent call last):
      ...
   SyntaxError: yield expression cannot be used within a TypeVar bound

   >>> def f[T: (int, (yield))](): pass
   Traceback (most recent call last):
      ...
   SyntaxError: yield expression cannot be used within a TypeVar constraint

   >>> def f[T = (yield)](): pass
   Traceback (most recent call last):
      ...
   SyntaxError: yield expression cannot be used within a TypeVar default

   >>> def f[*Ts = (yield)](): pass
   Traceback (most recent call last):
      ...
   SyntaxError: yield expression cannot be used within a TypeVarTuple default

   >>> def f[**P = [(yield), int]](): pass
   Traceback (most recent call last):
      ...
   SyntaxError: yield expression cannot be used within a ParamSpec default

   >>> type A[T: (yield 3)] = int
   Traceback (most recent call last):
      ...
   SyntaxError: yield expression cannot be used within a TypeVar bound

   >>> type A[T: (int, (yield 3))] = int
   Traceback (most recent call last):
      ...
   SyntaxError: yield expression cannot be used within a TypeVar constraint

   >>> type A[T = (yield 3)] = int
   Traceback (most recent call last):
      ...
   SyntaxError: yield expression cannot be used within a TypeVar default

   >>> type A[T: (await 3)] = int
   Traceback (most recent call last):
      ...
   SyntaxError: await expression cannot be used within a TypeVar bound

   >>> type A[T: (yield from [])] = int
   Traceback (most recent call last):
      ...
   SyntaxError: yield expression cannot be used within a TypeVar bound

   >>> class A[T: (yield 3)]: pass
   Traceback (most recent call last):
      ...
   SyntaxError: yield expression cannot be used within a TypeVar bound

   >>> class A[T: (int, (yield 3))]: pass
   Traceback (most recent call last):
      ...
   SyntaxError: yield expression cannot be used within a TypeVar constraint

   >>> class A[T = (yield)]: pass
   Traceback (most recent call last):
      ...
   SyntaxError: yield expression cannot be used within a TypeVar default

   >>> class A[*Ts = (yield)]: pass
   Traceback (most recent call last):
      ...
   SyntaxError: yield expression cannot be used within a TypeVarTuple default

   >>> class A[**P = [(yield), int]]: pass
   Traceback (most recent call last):
      ...
   SyntaxError: yield expression cannot be used within a ParamSpec default

   >>> type A = (x := 3)
   Traceback (most recent call last):
      ...
   SyntaxError: named expression cannot be used within a type alias

   >>> type A = (yield 3)
   Traceback (most recent call last):
      ...
   SyntaxError: yield expression cannot be used within a type alias

   >>> type A = (await 3)
   Traceback (most recent call last):
      ...
   SyntaxError: await expression cannot be used within a type alias

   >>> type A = (yield from [])
   Traceback (most recent call last):
      ...
   SyntaxError: yield expression cannot be used within a type alias

   >>> type __debug__ = int
   Traceback (most recent call last):
   SyntaxError: cannot assign to __debug__

   >>> class A[__debug__]: pass
   Traceback (most recent call last):
   SyntaxError: cannot assign to __debug__

   >>> class A[T]((x := 3)): ...
   Traceback (most recent call last):
      ...
   SyntaxError: named expression cannot be used within the definition of a generic

   >>> class A[T]((yield 3)): ...
   Traceback (most recent call last):
      ...
   SyntaxError: yield expression cannot be used within the definition of a generic

   >>> class A[T]((await 3)): ...
   Traceback (most recent call last):
      ...
   SyntaxError: await expression cannot be used within the definition of a generic

   >>> class A[T]((yield from [])): ...
   Traceback (most recent call last):
      ...
   SyntaxError: yield expression cannot be used within the definition of a generic

    >>> f(**x, *y)
    Traceback (most recent call last):
    SyntaxError: iterable argument unpacking follows keyword argument unpacking

    >>> f(**x, *)
    Traceback (most recent call last):
    SyntaxError: Invalid star expression

    >>> f(x, *:)
    Traceback (most recent call last):
    SyntaxError: Invalid star expression

    >>> f(x, *)
    Traceback (most recent call last):
    SyntaxError: Invalid star expression

    >>> f(x = 5, *)
    Traceback (most recent call last):
    SyntaxError: Invalid star expression

    >>> f(x = 5, *:)
    Traceback (most recent call last):
    SyntaxError: Invalid star expression

Asserts:

    >>> assert (a := 1)  # ok
    >>> assert 1, (a := 1)  # ok

    >>> assert a := 1
    Traceback (most recent call last):
    SyntaxError: cannot use named expression without parentheses here

    >>> assert 1, a := 1
    Traceback (most recent call last):
    SyntaxError: cannot use named expression without parentheses here

    >>> assert 1 = 2 = 3
    Traceback (most recent call last):
    SyntaxError: cannot assign to literal here. Maybe you meant '==' instead of '='?

    >>> assert 1 = 2
    Traceback (most recent call last):
    SyntaxError: cannot assign to literal here. Maybe you meant '==' instead of '='?

    >>> assert (1 = 2)
    Traceback (most recent call last):
    SyntaxError: cannot assign to literal here. Maybe you meant '==' instead of '='?

    >>> assert 'a' = a
    Traceback (most recent call last):
    SyntaxError: cannot assign to literal here. Maybe you meant '==' instead of '='?

    >>> assert x[0] = 1
    Traceback (most recent call last):
    SyntaxError: cannot assign to subscript here. Maybe you meant '==' instead of '='?

    >>> assert (yield a) = 2
    Traceback (most recent call last):
    SyntaxError: cannot assign to yield expression here. Maybe you meant '==' instead of '='?

    >>> assert a = 2
    Traceback (most recent call last):
    SyntaxError: cannot assign to name here. Maybe you meant '==' instead of '='?

    >>> assert (a = 2)
    Traceback (most recent call last):
    SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?

    >>> assert a = b
    Traceback (most recent call last):
    SyntaxError: cannot assign to name here. Maybe you meant '==' instead of '='?

    >>> assert 1, 1 = b
    Traceback (most recent call last):
    SyntaxError: cannot assign to literal here. Maybe you meant '==' instead of '='?

    >>> assert 1, (1 = b)
    Traceback (most recent call last):
    SyntaxError: cannot assign to literal here. Maybe you meant '==' instead of '='?

    >>> assert 1, a = 1
    Traceback (most recent call last):
    SyntaxError: cannot assign to name here. Maybe you meant '==' instead of '='?

    >>> assert 1, (a = 1)
    Traceback (most recent call last):
    SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?

    >>> assert 1 = a, a = 1
    Traceback (most recent call last):
    SyntaxError: cannot assign to literal here. Maybe you meant '==' instead of '='?

)�supportc�T`�\sQsQsnQ
QksQ
QksQsQsQsQs	Qs
Q	sUsP!)�SyntaxWarningTesti;c��UO[U29^tt^2[VU2PPP2P!)%fhP!9h)z�Check that compiling code raises SyntaxWarning with errtext.

errtest is a regular expression that must be present in the
text of the warning raised.
)�assertWarnsRegex�
SyntaxWarning�compile)�self�code�errtext�filename�modes&&&&&�%C:\Python315\\Lib\test\test_syntax.py�
check_warning�SyntaxWarningTest.check_warning<s0���
"�
"�=�'�
:�
:��D�D�)�;�
:�
:�
:�s�
7�A	�A	c���]PHoUOP	Q59^tt^2oUOQ2[VU2PPP2UO	W,2P!)%fhK$9h)z6Check that compiling code does not raise any warnings.)�record�always)�warnings�catch_warnings�simplefilterr�assertEqual)rr	rrr�caughts&&&&  r
�check_no_warning�"SyntaxWarningTest.check_no_warningEsS���
�
$�
$�D�
$�
1�
1�V��!�!�(�+��D�D�)�2�	
�����$�2�
1�s�A�A*	�#A*	c��[OQ2oUOUQ2[OQ2oUOUQ2[OQ2oUOUQ2P!)z�
            def f():
                try:
                    pass
                finally:
                    return 42
            z'return' in a 'finally' blockz�
            def f():
                try:
                    pass
                finally:
                    try:
                        return 42
                    except:
                        pass
            z�
            def f():
                try:
                    pass
                finally:
                    try:
                        pass
                    except:
                        return 42
            ��textwrap�dedentr�r�sources& r
�test_return_in_finally�(SyntaxWarningTest.test_return_in_finallyMst�����"���	
���6�#B�C����	"�	��	
���6�#B�C����	"�	��	
���6�#B�C�c�<�QFD�o[OQUQ02oUOUQUQ02[OQUQ02oUOUQUQ02[OQUQ02oUOUQUQ02J�	P!)	�breakz�
                for abc in range(10):
                    try:
                        pass
                    finally:
                        z
                �'z' in a 'finally' blockz�
                for abc in range(10):
                    try:
                        pass
                    finally:
                        try:
                            zR
                        except:
                            pass
                z�
                for abc in range(10):
                    try:
                        pass
                    finally:
                        try:
                            pass
                        except:
                            )r$�continuer)r�kwrs&  r
�"test_break_and_continue_in_finally�4SyntaxWarningTest.test_break_and_continue_in_finallyos���'�B��_�_�*�
���&��F�
���v��2�$�.D�'E�F��_�_�*� �D�!�
	&�	�F�
���v��2�$�.D�'E�F��_�_�*� �D�!�	&�	�F�
���v��2�$�.D�'E�F�C(r"c�L�UOQQ2UOQQ2UOQQ2UOQQ2UOQQ2UOQQ	2UOQ
Q2UOQQ2UOQQ2P!)
�from . lazy import x�"did you mean 'lazy from . import'?zfrom . lazy import x as yzfrom . lazy import *zfrom .. lazy import xz#did you mean 'lazy from .. import'?zfrom ... lazy import xz$did you mean 'lazy from ... import'?zfrom .... lazy import xz%did you mean 'lazy from .... import'?zfrom . \
    lazy import xzfrom .\
lazy import xzfrom .	lazy import x)r�rs&r
�test_from_lazy_imports�(SyntaxWarningTest.test_from_lazy_imports�s������"�0�	
�	
���'�0�	
�	
���"�0�	
�	
���#�1�	
�	
���$�2�	
�	
���%�3�	
�	
���*�0�	
�	
���%�0�	
�	
���#�0�	
r"c��UOQ2UOQ2UOQ2UOQ2UOQ2UOQ2UOQ2UOQ2UOQ2UOQ	2UOQ
2UOQ2UOQ2UOQ
2UOQ2P!)zfrom .lazy import xzfrom .lazy import *zfrom ..lazy import xzfrom ...lazy import xzfrom .lazy.sub import xzfrom ..lazy.sub import xzfrom ...lazy.sub import xzfrom . lazier import xzfrom . lazy_module import xzfrom . lazy.sub import xzfrom . sub.lazy import xzfrom lazy import xzfrom lazy.sub import xzlazy from . lazy import xzfrom . import lazy)rr-s&r
�test_not_from_lazy_imports�,SyntaxWarningTest.test_not_from_lazy_imports�s������3�4����3�4����4�5����5�6����7�8����8�9����9�:����6�7����;�<����8�9����8�9����2�3����6�7����9�:����2�3r"c	�>�]PHoUO29^tt^2UOQ[2UO	[
[OQ229^tt^2o[QQQ2PPP2PPP2UOWOO]2UOUOO]2UOUOO]2P!)%fhK�9h)%fhK�9h)��errorr,r+�<test>�exec)rrrr�assertRaisesRegex�SyntaxError�re�escaperr�	exception�lineno�offset�
end_offset)rr�cms&  r
�test_from_lazy_imports_as_error�1SyntaxWarningTest.test_from_lazy_imports_as_error�s����
�
$�
$�
&�
&��!�!�'�=�9��'�'���	�	�>�?�����.��&�A�	�'�	
������,�,�a�0�������,�,�a�0�������0�0�"�5����'�
&�s0�A	D�'C9	�5D�9D	
�D	
�D�D	�D	�)�
<testcase>r7)
�__name__�
__module__�__qualname__�__firstlineno__rrr r(r.r1rA�__static_attributes__�__classdictcell__��
__classdict__s@r
rr;s2����*�%� D�D"G�H%
�N4�"6�6r"rc�.`�\sQsQsnQ0QksQsQsQsQsQs	Qs
Q	sQ
sQs
QsQ
sQsQsQsQsQsQsQsQsQsQsQs\O8Q2s\O8Q2s\O8Q2s\O8Q2s Qs!Qs"Qs#Q s$Q!s%Q"s&Q#s'Q$s(Q%s)Q&s*\O8Q'2s+\O8Q(2s,\O8\OZ2Q)22s.Q*s/Q+s0Q,s1Q-s2Q.s3Q/s4Us5P!)1�SyntaxErrorTestCasei�c
��[VU2UOQ2P![Cc"o
S%c4[X�2%f#SOQSO*2[
OS[S
22oSeSOQS802SOS
OS2SdSOS
OS2SdSOS
OS2SdSOS
OS2S	d#SOS
OS	2Po
=
P!Po
=
P!Po
=
hh9h)z�Check that compiling code raises SyntaxError with errtext.

errtest is a regular expression that must be present in the
text of the exception raised.  If subclass is specified it
is the expected subclass of SyntaxError (e.g. IndentationError).
z#compile() did not raise SyntaxErrorzSyntaxError is not a %szSyntaxError did not contain )r�failr9�
isinstancerEr:�search�strrrr=r>�
end_linenor?)rr	r
rr�subclassr=r>rTr?�err�mos&&&&&&&&&&  r
�_check_error� SyntaxErrorTestCase._check_error�s��	=��D�D�)�$
�I�I�;�<��#�	=��
�3� 9� 9��	�	�3�h�6G�6G�G�H����7�C��H�-�B��z��	�	�g�G�H����S�\�\�8�4��!�� � ����V�4��!�� � ����V�4��%�� � �����<��%�� � �����<�<�&��	=�sC�"�
E�E�E
�E
�AE
�
4E
�E
�"E
�E
�"E
�
Ec�0�UOQQ]Q5P!)zprint(end1 + end2 = ' ')z=expression cannot contain assignment, perhaps you meant "=="?)r>�rXr-s&r
�test_expression_with_assignment�3SyntaxErrorTestCase.test_expression_with_assignment�s�����&�K��	�	
r"c�0�UOQQQQ5P!)zf{}�invalid syntax�single�rr[r-s&r
�1test_curly_brace_after_primary_raises_immediately�ESyntaxErrorTestCase.test_curly_brace_after_primary_raises_immediatelys�����%�!1���Ar"c�,�UOQQ2P!)zf() = 1�assignr[r-s&r
�test_assign_call�$SyntaxErrorTestCase.test_assign_calls�����)�X�.r"c���UOQQ2UOQQ2UOQQ2UOQQ2UOQQ2UOQ	Q
2UOQQ2UOQQ2UOQ
Q2UOQQ2UOQQ2UOQQ2UOQQ2UOQQ2UOQQ2UOQQ2UOQQ2UOQQ2UOQQ2UOQQ2UOQQ2UOQQ2UOQQ2UOQQ2UOQ Q2UOQ!Q"2UOQ#Q2P!)$zdel (,)r_zdel 1zcannot delete literalz
del (1, 2)zdel Nonezcannot delete Nonezdel *xzcannot delete starredzdel (*x)zcannot use starred expressionz	del (*x,)z	del [*x,]zdel f()zcannot delete function callzdel f(a, b)z	del o.f()z
del a[0]()z
del x, f()z
del f(), xzdel [a, b, ((c), (d,), e.f())]zdel (a if True else b)zcannot delete conditionalzdel +azcannot delete expressionz	del a, +bz	del a + bzdel (a + b, c)zdel (c[0], a + b)z
del a.b.c + 2zdel a.b.c[0] + 2zdel (a, b, (c, d.e.f + 2))zdel [a, b, (c, d.e.f[0] + 2)]zdel (a := 5)zcannot delete named expressionz
del a += br[r-s&r
�test_assign_del�#SyntaxErrorTestCase.test_assign_dels������)�%5�6����'�#:�;����,�(?�@����*�&:�;����(�$;�<����*�&E�F����+�'>�?����+�'>�?����)�%B�C����-�)F�G����+�'D�E����,�(E�F����,�(E�F����,�(E�F����:�<Y�Z����2�4O�P����(�$>�?����+�'A�B����+�'A�B����*�,F�G����-�/I�J����/�+E�F����,�.H�I����6�8R�S����9�;U�V����.�*J�K�	
���,�(8�9r"c�4�QoUOUQ]Q5P!)z�if 1:
            def error(a):
                global a  # SyntaxError
            def error2():
                b = 1
                global b  # SyntaxError
            zparameter and global�r=r[rs& r
�test_global_param_err_first�/SyntaxErrorTestCase.test_global_param_err_first%s!����	
���&�"8���Cr"c�4�QoUOUQ]Q5P!)z�if 1:
            def error(a):
                nonlocal a  # SyntaxError
            def error2():
                b = 1
                global b  # SyntaxError
            zparameter and nonlocalrlr[rs& r
�test_nonlocal_param_err_first�1SyntaxErrorTestCase.test_nonlocal_param_err_first/s!����	
���&�":�1��Er"c�4�QoUOUQ]Q5P!)zKif 1:
        raise AssertionError() from None
        print(1,,2)
        r_rlr[rs& r
�test_raise_from_error_message�1SyntaxErrorTestCase.test_raise_from_error_message9s!����	
���&�"2�1��=r"c�L�UOQQ2UOQQ2UOQQ2UOQQ2UOQQ2UOQQ2UOQQ2UOQQ2UOQ	Q2P!)
zif 0: yield�outside functionzif 0: yield
else:  x=1zif 1: pass
else: yieldzwhile 0: yieldzwhile 0: yield
else:  x=1zclass C:
  if 0: yieldz#class C:
  if 1: pass
  else: yieldzclass C:
  while 0: yieldz(class C:
  while 0: yield
  else:  x = 1r[r-s&r
�test_yield_outside_function�/SyntaxErrorTestCase.test_yield_outside_function@s������-�8J�K����3�8J�K����3�8J�K����*�8J�K����6�8J�K����3�8J�K����A�,�	.����6�8J�K����F�,�	.r"c�L�UOQQ2UOQQ2UOQQ2UOQQ2UOQQ2UOQQ2UOQQ2UOQQ2UOQ	Q2P!)
zif 0: returnrvzif 0: return
else:  x=1zif 1: pass
else: returnzwhile 0: returnzclass C:
  if 0: returnzclass C:
  while 0: returnz'class C:
  while 0: return
  else:  x=1z$class C:
  if 0: return
  else: x= 1z$class C:
  if 1: pass
  else: returnr[r-s&r
�test_return_outside_function�0SyntaxErrorTestCase.test_return_outside_functionMs������.�9K�L����4�9K�L����4�9K�L����+�9K�L����4�9K�L����7�9K�L����E�,�	.����B�,�	.����B�,�	.r"c�$�QoUOQU]Q5UOQU]Q5UOQU]Q5UOQU]Q5UOQU]Q5UOQU]Q5UOQU]Q5P!)	zoutside loopr$rlzif 0: breakzif 0: break
else:  x=1zif 1: pass
else: breakzclass C:
  if 0: breakz#class C:
  if 1: pass
  else: breakzwith object() as obj:
 breakr[�r�msgs& r
�test_break_outside_loop�+SyntaxErrorTestCase.test_break_outside_loop[s��������'�3�q��1����-��Q��7����3�S���C����3�S���C����3�S���C����A��a�	�	)����9��a�	�	)r"c��QoUOQU]Q5UOQU]Q5UOQU]Q5UOQU]Q5UOQU]Q5UOQU]Q5P!)znot properly in loopzif 0: continuerlzif 0: continue
else:  x=1zif 1: pass
else: continuezclass C:
  if 0: continuez&class C:
  if 1: pass
  else: continuez"with object() as obj:
    continuer[r}s& r
�test_continue_outside_loop�.SyntaxErrorTestCase.test_continue_outside_loopgs���$�����*�C���:����6��A��F����6��A��F����6��A��F����D��a�	�	)����?��a�	�	)r"c�8�UOQQ[Q5P!)z
foo()
 bar()
zunexpected indent�rU�rX�IndentationErrorr-s&r
�test_unexpected_indent�*SyntaxErrorTestCase.test_unexpected_indentrs�����+�-@�#3�	�	5r"c�8�UOQQ[Q5P!)zif 1:
foo()zexpected an indented blockr�r�r-s&r
�test_no_indent�"SyntaxErrorTestCase.test_no_indentvs�����.�*F�#3�	�	5r"c�8�UOQQ[Q5P!)zif 1:
  foo()
 bar()z unindent does not match .* levelr�r�r-s&r
�test_bad_outdent�$SyntaxErrorTestCase.test_bad_outdentzs�����2�<�#3�	�	5r"c�,�UOQQ2P!)zint(base=10, '2')z,positional argument follows keyword argumentr[r-s&r
�test_kwargs_last�$SyntaxErrorTestCase.test_kwargs_lasts�����-�H�	Jr"c�,�UOQQ2P!)zint(**{'base': 10}, '2')z6positional argument follows keyword argument unpackingr[r-s&r
�test_kwargs_last2�%SyntaxErrorTestCase.test_kwargs_last2�s�����4�7�	8r"c�,�UOQQ2P!)zint(**{'base': 10}, *['2'])z>iterable argument unpacking follows keyword argument unpackingr[r-s&r
�test_kwargs_last3�%SyntaxErrorTestCase.test_kwargs_last3�s�����7�7�	8r"c	�6�UOQQ]]]]5Q5P!)z<foo(x,    y for y in range(3) for z in range(2) if z    , p)z*Generator expression must be parenthesized�r=rTr>r?r[r-s&r
�test_generator_in_function_call�3SyntaxErrorTestCase.test_generator_in_function_call�s%�����X�F�!"�q���	�	Lr"c	�6�UOQQ]]]]Q5P!)z9try: pass
except ValueError: pass
except* TypeError: pass�:cannot have both 'except' and 'except\*' on the same 'try'r�r[r-s&r
�test_except_then_except_star�0SyntaxErrorTestCase.test_except_then_except_star��%�����W�W�!"�q��q�	�	Jr"c	�6�UOQQ]]]]Q5P!)z9try: pass
except* ValueError: pass
except TypeError: passr�r�r[r-s&r
�test_except_star_then_except�0SyntaxErrorTestCase.test_except_star_then_except�r�r"c���Qo[UQQ2QoQo[UQQ2[UQQ2P![cSOQ2K?h9h[cSOQ2P!h9h)z\
pass
        \

pass
�<string>r7z8Empty line after a line continuation character is valid.zN\
def fib(n):
    \
'''Print a Fibonacci series up to n.'''
    \
a, b = 0, 1
zJ\
def fib(n):
    '''Print a Fibonacci series up to n.'''
    a, b = 0, 1
z/Indented statement over multiple lines is valid)rr9rP)r�s�s1�s2s&   r
�test_empty_line_after_linecont�2SyntaxErrorTestCase.test_empty_line_after_linecont�s���
��	R��A�z�6�*�
����
	I��B�
�F�+��B�
�F�+��%�	R��I�I�P�Q�	R��&�	I��I�I�G�H�	I�s+�
3�A�	A�A�A�	A5�A5�4A5c�B�QoUO[[U2P!)z(\
if x:
    y = 1
  \
  foo = 1
        )�assertRaisesr�r7�rr	s& r
�!test_continuation_bad_indentation�5SyntaxErrorTestCase.test_continuation_bad_indentation�s����	
���*�D�$�7r"c��UOQQ2UOQQ2UOQQ2Q	FDo[QUQ0QQQ5J	P!)
zclass A[__classdict__]: passz?reserved name '__classdict__' cannot be used for type parameterzdef f[__classdict__](): passz,type T[__classdict__] = tuple[__classdict__]z
class A:
    class B[z]: pass
                rDr7ra)�	__class__�
__classcell__rJ)rXr)r�names& r
� test_disallowed_type_param_names�4SyntaxErrorTestCase.test_disallowed_type_param_names�st��	
���8�Y�	\����8�Y�	\����H�Y�	\�
H�D��
�
�F���"��
0�Hr"c���Po[]2FDCoUQU*Q0*
oUQU]**Q0*
oUQU*Q0*
oJE	UQQ0*
oUOUQ2P!)�z    ztry:
zraise Exception
zexcept Exception as e:
�pass�!too many statically nested blocksz0                                                )�rangerX)rr	�is&  r
�test_nested_named_except_blocks�3SyntaxErrorTestCase.test_nested_named_except_blocks�s~�����r��A��v�a�x�j��'�'�D��v�q��s�|�n�$5�6�6�D��v�a�x�j� 8�9�9�D��	
�8�*�D�!�!�����$� C�Dr"c	��Qo]oU]*
o[U2FD<oUOQU8029^tt^2[UU2QQ2PPP2J>	[V3]*2FDAoUOQU8029^tt^2UOUU2Q2PPP2JC	P!)%fhJ�9h)%fhJl9h)c��[OQ2o[U2FDoUQUQ0*
oJ	UQ*
oU!)z]
                def bug():
                    with (
                    a
                �    as a�, a
�
): yield a)rrr���nr	r�s&  r
�get_code�OSyntaxErrorTestCase.test_with_statement_many_context_managers.<locals>.get_code�sG���?�?�$��D�
�1�X���(�1�#�U�+�+����L� �D��Kr"�within range: n=r�r7�out of range: n=r��r��subTestrrX�rr��CO_MAXBLOCKS�MAX_MANAGERSr�s&    r
�)test_with_statement_many_context_managers�=SyntaxErrorTestCase.test_with_statement_many_context_managers�s���		���#�a�'���|�$�A���� 1�q�d�3�4�4�����Z��8�5�4�%��|�A�%5�6�A���� 1�q�d�3�4�4��!�!�(�1�+�/R�S�5�4�7�5�4�4��5�4�4��#�B6	�C
	�6C
�?C
�
C
�C
c	��Qo]oU]*
o[U2FD<oUOQU8029^tt^2[UU2QQ2PPP2J>	[V3]*2FDAoUOQU8029^tt^2UOUU2Q2PPP2JC	P!)%fhJ�9h)%fhJl9h)c���[OQ2,o[U2FDoUOQUQ02J	UOQ2PO	U2!)zi
                async def bug():
                    async with (
                    a
                r�r�r�)rrr��append�joinr�s&  r
r��USyntaxErrorTestCase.test_async_with_statement_many_context_managers.<locals>.get_code
sY���_�_�&���D�
�1�X�����h�q�c��/�0���K�K��%��7�7�4�=� r"r�r�r7r�r�r�r�s&    r
�/test_async_with_statement_many_context_managers�CSyntaxErrorTestCase.test_async_with_statement_many_context_managers�s���		!���#�a�'���|�$�A���� 1�q�d�3�4�4�����Z��8�5�4�%��|�A�%5�6�A���� 1�q�d�3�4�4��!�!�(�1�+�/R�S�5�4�7�5�4�4��5�4�4�r�c�0�QoUOUQ2P!)zw
def func1():
    if a != b:
        raise ValueError

def func2():
    try
        return 1
    finally:
        pass
zexpected ':'r[r�s& r
�&test_barry_as_flufl_with_syntax_errors�:SyntaxErrorTestCase.test_barry_as_flufl_with_syntax_errors
s��
��	
���$��/r"c��UOQQ]]Q5UOQQ]]Q5UOQQ]]Q5P!)z	a = 3 \ 4�6unexpected character after line continuation character)r=r>z1,\#
2z
fgdfgf
1,\#
2
r[r-s&r
�-test_invalid_line_continuation_error_position�ASyntaxErrorTestCase.test_invalid_line_continuation_error_position*
s^�����,�R�!"�1�	�	.�	
���*�R�!"�1�	�	.�	
���0�R�!"�1�	�	.r"c�P�UOQQ2UOQQ2P!)uA.Ɗ\ r�uA.μ\
zunexpected EOF while parsingr[r-s&r
�-test_invalid_line_continuation_left_recursive�ASyntaxErrorTestCase.test_invalid_line_continuation_left_recursive5
s+��	
���-�R�	T����.�8�	:r"c�`�QFD oUOUQ*QUQ02J"	QFDoUOQUQ0QUQ02J	QFD oUOUQ*QUQ02J"	Q	oUOUQ
2UOQQ2Q
oUOUQ2P!)z([{z1 + 2�\z' was never closedza = z 1, 2, 3
b=3z)]}zunmatched '\r%zFfunc(
    a=["unclosed], # Need a quote in this comment: "
    b=2,
)
z8parenthesis '\)' does not match opening parenthesis '\['zmatch y:
 case e(e=v,v,z was never closeds.# coding=latin
(aaaaaaaaaaaaaaaaa
aaaaaaaaaaa�z'\(' was never closedr[)r�parenr	r�s&   r
�test_error_parenthesis�*SyntaxErrorTestCase.test_error_parenthesis=
s����E����e�g�o��E�7�:L�/M�N���E�����U�G�=�9�R��w�FX�;Y�Z���E����e�g�o��u�g�Q�/G�H����	
���$� \�]����4�6I�J�
C�����!�5�6r"c���UOQQ2UOQQ2UOQQ2UOQQ2UOQQ2UOQQ2P!)	z'blechz#unterminated string literal \(.*\)$z"blechz"blech\"zEunterminated string literal \(.*\); perhaps you escaped the end quotez	r"blech\"z'''blechz)unterminated triple-quoted string literalz"""blechr[r-s&r
�test_error_string_literal�-SyntaxErrorTestCase.test_error_string_literalV
sr�����(�$J�K����(�$J�K�����a�	
�	
����b�	
�	
���*�&Q�R����*�&Q�Rr"c�P�UOQQ2UOQQ2P!)zprint("Hello")zinvalid non-printable characterswith(0,,):
r[r-s&r
�test_invisible_characters�-SyntaxErrorTestCase.test_invisible_charactersc
s&�����.�0Q�R����-�/P�Qr"c�&�Qo[UQQ2P!)z)
def match(x):
    return 1+1

match(34)
r�r7�rr�s& r
�+test_match_call_does_not_raise_syntax_error�?SyntaxErrorTestCase.test_match_call_does_not_raise_syntax_errorg
�����	��j�&�)r"c�&�Qo[UQQ2P!)z'
def case(x):
    return 1+1

case(34)
r�r7r�r�s& r
�*test_case_call_does_not_raise_syntax_error�>SyntaxErrorTestCase.test_case_call_does_not_raise_syntax_errorp
r�r"c�0�UOQQ]Q5P!)zcall(
a=1,
a=1
)zkeyword argument repeatedrlr[r-s&r
�/test_multiline_compiler_error_points_to_the_end�CSyntaxErrorTestCase.test_multiline_compiler_error_points_to_the_endy
s�����!�'��	�	
r"c�0�UOQQ]Q5P!)z4print(
    "line1"
    "line2"
    "line3"
    x=1
)zPerhaps you forgot a commarlr[r-s&r
�@test_multiline_string_concat_missing_comma_points_to_last_string�TSyntaxErrorTestCase.test_multiline_string_concat_missing_comma_points_to_last_string�
s$��	
���
�
)��	�		
r"c�0�QoUOUQ2P!)a�
while 1:
 while 2:
  while 3:
   while 4:
    while 5:
     while 6:
      while 8:
       while 9:
        while 10:
         while 11:
          while 12:
           while 13:
            while 14:
             while 15:
              while 16:
               while 17:
                while 18:
                 while 19:
                  while 20:
                   while 21:
                    while 22:
                     while 23:
                      break
r�r[rs& r
�)test_syntax_error_on_deeply_nested_blocks�=SyntaxErrorTestCase.test_syntax_error_on_deeply_nested_blocks�
s����2	
���&�"E�Fr"c�8�QQ*Q*oQFDZoUOUQ59^tt^2UO[Q29^tt^2[UQU2PPP2PPP2J\	P!)%fhK9h)%fhJ�9h)�-i���4raztoo complexr�)r7�evalr`)r�r8�MemoryErrorr)rrrs&  r
�#test_error_on_parser_stack_overflow�7SyntaxErrorTestCase.test_error_on_parser_stack_overflow�
sk���v���#��.�D����4��(�(��+�+�K��H�H��F�J��5�I�)�(�/�H�H��)�(�(�s/�B	�A5
�B	�5B�>B�B	�B
�B
c��QoUO[29^tt^2[UQQ2PPP2P!)%fhP!9h)z,d{{{{{{{{{{{{{{{{{{{{{{{{{```{{{{{{{ef f():yr�r7)r�r9rrs& r
�test_deep_invalid_rule�*SyntaxErrorTestCase.test_deep_invalid_rule�
s6��
@��
�
�
�{�
+�
+��F�J��/�,�
+�
+�
+�s�9�A
	�A
	c�~�UO[OQ2Q]]]][Q2*Q5P!)z�
                try:
                    pass
                except ValueError as obj.attr:
                    pass
                z*cannot use except statement with attribute�obj.attr�r
r=rTr>r?�rXrr�lenr-s&r
� test_except_stmt_invalid_as_expr�4SyntaxErrorTestCase.test_except_stmt_invalid_as_expr�
sA������O�O��
�A�����C�
�O�+�	�	
r"c�~�UO[OQ2Q]]]][Q2*Q5P!)zn
                match 1:
                    case x as obj.attr:
                        ...
                z&cannot use attribute as pattern targetr
rrr-s&r
�test_match_stmt_invalid_as_expr�3SyntaxErrorTestCase.test_match_stmt_invalid_as_expr�
s@������O�O��
�=�����C�
�O�+�	�
	
r"c�J�QoQFDoUOQU0U2J	P!)z8expected expression after 'else', but statement is givenzx = 1 if 1 else )
r��returnzreturn 2zraise Exception('a')zdel azyield 2zassert Falser$r&�import�
import ast�fromzfrom ast import *r[�rr~�stmts&  r
�test_ifexp_else_stmt�(SyntaxErrorTestCase.test_ifexp_else_stmt�
s-��H��
�D�
��� 0���7��=�
r"c�L�QoQFDoUOQUQ0U2J	P!)�7expected expression before 'if', but statement is given�x = z if 1 else 1)r�r$r&r[rs&  r
�$test_ifexp_body_stmt_else_expression�8SyntaxErrorTestCase.test_ifexp_body_stmt_else_expression�
s.��G��
�D�

����T�F�,�7��=�
r"c�T�QoQFDvq#UOQUQU0U2J	P!)rrz if 1 else ))r�r�)r$r�)r&rr[)rr~�lhs_stmt�rhs_stmts&   r
�test_ifexp_body_stmt_else_stmt�2SyntaxErrorTestCase.test_ifexp_body_stmt_else_stmts5��G��#
��H�

����X�J�k�(��D�c�J�#
r"rC)rDr7NNNNN)6rErFrGrHrXr\rbrfrirmrprsrwrzrr�r�r�r�r�r�r�r�r�r�r�r�r�cpython_onlyr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�skip_wasi_stack_overflowrrrrrr$rIrJrKs@r
rNrN�s�����=�<
�B�/�:�>D�F�>�.�.�
)�	)�5�5�5�
J�8�
8�
L�
J�
J�
I�@
8�
���0��0�$
���E��E�
���T��T�2
���T��T�20�"	.�:�7�2S�R�*�*�
�
�
���!G��!G�F
���6��6�
����%�%�'�0�(��0�
�"
� >�(>�K�Kr"rNc�\`�\sQsQsnQsQsQsQsQsQs	Qs
Q	sQ
sQs
QsUsP!)
�LazyImportRestrictionTestCaseiz*Test syntax restrictions for lazy imports.c�P�UOQQ2UOQQ2P!)z9Test that lazy imports are not allowed inside try blocks.z)try:
    lazy import os
except:
    pass
�0lazy import not allowed inside try/except blocksz@try:
    lazy from sys import path
except ImportError:
    pass
�9lazy from ... import not allowed inside try/except blocksr[r-s&r
�test_lazy_import_in_try_block�;LazyImportRestrictionTestCase.test_lazy_import_in_try_block�6������
8�	9�	
����
A�	Br"c�P�UOQQ2UOQQ2P!)z:Test that lazy imports are not allowed inside try* blocks.z6try:
    lazy import json
except* Exception:
    pass
r+zPtry:
    lazy from collections import defaultdict
except* ImportError:
    pass
r,r[r-s&r
�!test_lazy_import_in_trystar_block�?LazyImportRestrictionTestCase.test_lazy_import_in_trystar_blockr/r"c�,�UOQQ2P!)z<Test that lazy imports are not allowed inside except blocks.zVtry:
    sys.modules # trigger the except block
except* Exception:
   lazy import sys
r+r[r-s&r
� test_lazy_import_in_except_block�>LazyImportRestrictionTestCase.test_lazy_import_in_except_block/s������
8�	9r"c�P�UOQQ2UOQQ2P!)z8Test that lazy imports are not allowed inside functions.z!def func():
    lazy import math
�(lazy import not allowed inside functionsz3def func():
    lazy from datetime import datetime
�1lazy from ... import not allowed inside functionsr[r-s&r
�test_lazy_import_in_function�:LazyImportRestrictionTestCase.test_lazy_import_in_function8�4������0�	1�
	
����9�	:r"c�P�UOQQ2UOQQ2P!)z>Test that lazy imports are not allowed inside async functions.z0async def async_func():
    lazy import asyncio
r7z8async def async_func():
    lazy from json import loads
r8r[r-s&r
�"test_lazy_import_in_async_function�@LazyImportRestrictionTestCase.test_lazy_import_in_async_functionDr;r"c�P�UOQQ2UOQQ2P!)z6Test that lazy imports are not allowed inside classes.z&class MyClass:
    lazy import typing
�&lazy import not allowed inside classesz,class MyClass:
    lazy from abc import ABC
z/lazy from ... import not allowed inside classesr[r-s&r
�test_lazy_import_in_class�7LazyImportRestrictionTestCase.test_lazy_import_in_classPs4������.�	/�
	
����7�	8r"c�P�UOQQ2UOQQ2P!)z;Test that 'lazy from ... import *' is forbidden everywhere.zlazy from os import *z&lazy from ... import \* is not allowedz'def func():
    lazy from sys import *
r8r[r-s&r
�test_lazy_import_star_forbidden�=LazyImportRestrictionTestCase.test_lazy_import_star_forbidden\s3��	
���1�B�	D�	
����9�	:r"c�(�UOQQ2UOQQ2UOQQ2UOQQ2UOQ	Q2UOQ
Q2UOQQ2UOQQ2P!)
z#Test lazy imports in nested scopes.z;class Outer:
    def method(self):
        lazy import sys
r7z7def outer():
    class Inner:
        lazy import json
r@zIdef outer():
    def inner():
        lazy from collections import deque
r8zfrom os lazy import path
z6use 'lazy from ... ' instead of 'from ... lazy import'zfrom os.path lazy import join
zfrom .mod lazy import join
zfrom ..mod lazy import join
zfrom ...mod lazy import join
r[r-s&r
�test_lazy_import_nested_scopes�<LazyImportRestrictionTestCase.test_lazy_import_nested_scopeshs�������0�		1�	
����.�		/�	
����9�		:�	
����=�	?�	
����=�	?�	
����=�	?�	
����=�	?�	
����=�	?r"c�p�[QQQ2[QQQ2[QQQ2[QQQ2P!)z,Test that lazy imports work at module level.zlazy import osr6r7zlazy from sys import pathzlazy import json as jz(lazy from datetime import datetime as dtr�r-s&r
�test_lazy_import_valid_cases�:LazyImportRestrictionTestCase.test_lazy_import_valid_cases�s8��	� �(�F�3��+�X�v�>��'��6�:��:�H�f�Mr"rC)rErFrGrH�__doc__r-r1r4r9r=rArDrGrJrIrJrKs@r
r)r)s?����4�B� B� 9�
:�
:�
8�
:�"?�HN�Nr"r)c�P�UO[O22U!)N)�addTest�doctest�DocTestSuite)�loader�tests�patterns&&&r
�
load_testsrT�s��	�M�M�'�&�&�(�)��Lr"�__main__)rLr:rOr�unittest�testr�TestCaserrNr)rTrE�mainrCr"r
�<module>rZsy��q,�fY
�����[6��)�)�[6�|pK�(�+�+�pK�fFN�$7�FN�R�
�z���M�M�O�r"

Youez - 2016 - github.com/yon3zu
LinuXploit