+
    Bi~                        ^ RI t ^ RIt^ RIt^ RIt^ RIHt  ! R R]P                  4      t ! R R]P                  4      tR t	]
R8X  d   ]P                  ! 4        R# R# )	    N)supportc                   6   a  ] tR tRt o RR ltR tR tRtV tR# )SyntaxWarningTestit
  c                    V P                  \        V4      ;_uu_ 4        \        WV4       R R R 4       R #   + '       g   i     R # ; iN)assertWarnsRegexSyntaxWarningcompile)selfcodeerrtextfilenamemodes   &&&&&'/usr/lib/python3.14/test/test_syntax.pycheck_warningSyntaxWarningTest.check_warningu
  s0     ""='::DD) ;:::s	   6A	c                    \         P                  ! R 4      pV P                  VR4       \         P                  ! R4      pV P                  VR4       \         P                  ! R4      pV P                  VR4       R# )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
            Ntextwrapdedentr   r   sources   & r   test_return_in_finally(SyntaxWarningTest.test_return_in_finally~
  st     "  	6#BC 	" 	 	6#BC 	" 	 	6#BC    c                8   R	 F  p\         P                  ! RV R24      pV P                  VRV R24       \         P                  ! RV R24      pV P                  VRV R24       \         P                  ! RV R24      pV P                  VRV R24       K  	  R# )
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:
                            N)r   continuer   )r   kwr   s   &  r   "test_break_and_continue_in_finally4SyntaxWarningTest.test_break_and_continue_in_finally
  s    'B__ *
  & F v2$.D'EF__ *  D !	& 	F v2$.D'EF__ *  D !	& 	F v2$.D'EFC (r    N)
<testcase>exec)	__name__
__module____qualname____firstlineno__r   r   r!   __static_attributes____classdictcell____classdict__s   @r   r   r   t
  s     * DD"G "Gr   r   c                      a  ] tR tRt o R/R ltR tR tR tR tR t	R	 t
R
 tR tR tR tR tR tR tR tR tR tR tR tR tR tR t]P6                  R 4       t]P6                  R 4       t]P6                  R 4       t]P6                  R 4       tR t R t!R t"R  t#R! t$R" t%R# t&R$ t'R% t(]P6                  R& 4       t)]P6                  R' 4       t*]P6                  ]PV                  ! 4       R( 4       4       t,R) t-R* t.R+ t/R, t0R- t1R.t2V t3R# )0SyntaxErrorTestCasei
  Nc
                    \        WV4       V P                  R 4       R#   \         Ed"   p
T'       d4   \        Y4      '       g#   T P                  RTP                  ,          4       \
        P                  ! T\        T
4      4      pTf   T P                  RT: 24       T P                  T
P                  T4       Te   T P                  T
P                  T4       Te   T P                  T
P                  T4       Te   T P                  T
P                  T4       T	e#   T P                  T
P                  T	4        Rp
?
R#  Rp
?
R# Rp
?
ii ; i)z#compile() did not raise SyntaxErrorzSyntaxError is not a %sNzSyntaxError did not contain )r
   failSyntaxError
isinstancer&   researchstrassertEqualr   linenooffset
end_lineno
end_offset)r   r   r   r   r   subclassr8   r9   r:   r;   errmos   &&&&&&&&&&  r   _check_error SyntaxErrorTestCase._check_error
  s   	=DD)$ II;<#  	=
3 9 9		3h6G6GGH7CH-Bz		gGHS\\84!  V4!  V4%  <%  << &	=s   ! EDE		Ec                .    V P                  R R^R7       R# )zprint(end1 + end2 = ' ')z=expression cannot contain assignment, perhaps you meant "=="?)r9   Nr?   r   s   &r   test_expression_with_assignment3SyntaxErrorTestCase.test_expression_with_assignment
  s    &K 	 	
r   c                .    V P                  R RRR7       R# )zf{}invalid syntaxsingler   NrB   rC   s   &r   1test_curly_brace_after_primary_raises_immediatelyESyntaxErrorTestCase.test_curly_brace_after_primary_raises_immediately
  s    %!1Ar   c                *    V P                  R R4       R# )zf() = 1assignNrB   rC   s   &r   test_assign_call$SyntaxErrorTestCase.test_assign_call
  s    )X.r   c                   V P                  R R4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  R	R
4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  R R4       V P                  R!R"4       V P                  R#R4       R$# )%zdel (,)rG   zdel 1zcannot delete literalz
del (1, 2)zdel Nonezcannot delete Nonezdel *xzcannot delete starredzdel (*x)zcannot use starred expressionz	del (*x,)z	del [*x,]zdel f()zcannot delete function callzdel f(a, b)z	del o.f()z
del a[0]()z
del x, f()z
del f(), xzdel [a, b, ((c), (d,), e.f())]zdel (a if True else b)zcannot delete conditionalzdel +azcannot delete expressionz	del a, +bz	del a + bzdel (a + b, c)zdel (c[0], a + b)zdel a.b.c + 2zdel a.b.c[0] + 2zdel (a, b, (c, d.e.f + 2))zdel [a, b, (c, d.e.f[0] + 2)]zdel (a := 5)zcannot delete named expressionz
del a += bNrB   rC   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24OP($>?+'AB+'AB*,FG-/IJ/+EF,.HI68RS9;UV.*JK 	,(89r   c                2    R pV P                  VR^R7       R# )zif 1:
            def error(a):
                global a  # SyntaxError
            def error2():
                b = 1
                global b  # SyntaxError
            zparameter and globalr8   NrB   r   s   & r   test_global_param_err_first/SyntaxErrorTestCase.test_global_param_err_first  s!     	&"8Cr   c                2    R pV P                  VR^R7       R# )zif 1:
            def error(a):
                nonlocal a  # SyntaxError
            def error2():
                b = 1
                global b  # SyntaxError
            zparameter and nonlocalrT   NrB   r   s   & r   test_nonlocal_param_err_first1SyntaxErrorTestCase.test_nonlocal_param_err_first  s!     	&":1Er   c                J   V P                  R R4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  R	R4       R
# )zif 0: yieldoutside functionzif 0: yield
else:  x=1zif 1: pass
else: yieldzwhile 0: yieldzwhile 0: yield
else:  x=1zclass C:
  if 0: yieldz#class C:
  if 1: pass
  else: yieldzclass C:
  while 0: yieldz(class C:
  while 0: yield
  else:  x = 1NrB   rC   s   &r   test_yield_outside_function/SyntaxErrorTestCase.test_yield_outside_function%  s    -8JK38JK38JK*8JK68JK38JKA,	.68JKF,	.r   c                J   V P                  R R4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  R	R4       R
# )zif 0: returnr[   zif 0: return
else:  x=1zif 1: pass
else: returnzwhile 0: returnzclass C:
  if 0: returnzclass 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: returnNrB   rC   s   &r   test_return_outside_function0SyntaxErrorTestCase.test_return_outside_function2  s    .9KL49KL49KL+9KL49KL79KLE,	.B,	.B,	.r   c                "   R pV P                  RV^R7       V P                  RV^R7       V P                  RV^R7       V P                  RV^R7       V P                  RV^R7       V P                  RV^R7       V P                  RV^R7       R	# )
zoutside loopr   rT   zif 0: breakzif 0: break
else:  x=1zif 1: pass
else: breakzclass C:
  if 0: breakz#class C:
  if 1: pass
  else: breakzwith object() as obj:
 breakNrB   r   msgs   & r   test_break_outside_loop+SyntaxErrorTestCase.test_break_outside_loop@  s    '3q1-Q73SC3SC3SCAa 	 	)9a 	 	)r   c                    R pV P                  RV^R7       V P                  RV^R7       V P                  RV^R7       V P                  RV^R7       V P                  RV^R7       V P                  RV^R7       R# )	znot properly in loopzif 0: continuerT   zif 0: continue
else:  x=1zif 1: pass
else: continuezclass C:
  if 0: continuez&class C:
  if 1: pass
  else: continuez"with object() as obj:
    continueNrB   rb   s   & r   test_continue_outside_loop.SyntaxErrorTestCase.test_continue_outside_loopL  s    $*C:6AF6AF6AFDa 	 	)?a 	 	)r   c                6    V P                  R R\        R7       R# )zfoo()
 bar()
zunexpected indentr<   Nr?   IndentationErrorrC   s   &r   test_unexpected_indent*SyntaxErrorTestCase.test_unexpected_indentW  s    +-@#3 	 	5r   c                6    V P                  R R\        R7       R# )zif 1:
foo()zexpected an indented blockrj   Nrk   rC   s   &r   test_no_indent"SyntaxErrorTestCase.test_no_indent[  s    .*F#3 	 	5r   c                6    V P                  R R\        R7       R# )zif 1:
  foo()
 bar()z unindent does not match .* levelrj   Nrk   rC   s   &r   test_bad_outdent$SyntaxErrorTestCase.test_bad_outdent_  s    2<#3 	 	5r   c                *    V P                  R R4       R# )zint(base=10, '2')z,positional argument follows keyword argumentNrB   rC   s   &r   test_kwargs_last$SyntaxErrorTestCase.test_kwargs_lastd  s    -H	Jr   c                *    V P                  R R4       R# )zint(**{'base': 10}, '2')z6positional argument follows keyword argument unpackingNrB   rC   s   &r   test_kwargs_last2%SyntaxErrorTestCase.test_kwargs_last2h  s    47	8r   c                *    V P                  R R4       R# )zint(**{'base': 10}, *['2'])z>iterable argument unpacking follows keyword argument unpackingNrB   rC   s   &r   test_kwargs_last3%SyntaxErrorTestCase.test_kwargs_last3m  s    77	8r   c           	     4    V P                  R R^^^^5R7       R# )z<foo(x,    y for y in range(3) for z in range(2) if z    , p)z*Generator expression must be parenthesizedr8   r:   r9   r;   NrB   rC   s   &r   test_generator_in_function_call3SyntaxErrorTestCase.test_generator_in_function_callr  s%    XF!"q 	 	Lr   c           	     4    V P                  R R^^^^R7       R# )z9try: pass
except ValueError: pass
except* TypeError: pass:cannot have both 'except' and 'except\*' on the same 'try'r   NrB   rC   s   &r   test_except_then_except_star0SyntaxErrorTestCase.test_except_then_except_starw  %    WW!"qq 	 	Jr   c           	     4    V P                  R R^^^^R7       R# )z9try: pass
except* ValueError: pass
except TypeError: passr   r   NrB   rC   s   &r   test_except_star_then_except0SyntaxErrorTestCase.test_except_star_then_except|  r   r   c                    R p \        VRR4       RpRp \        VRR4       \        VRR4       R#   \         d    T P                  R4        L?i ; i  \         d    T P                  R4        R# i ; i)z\
pass
        \

pass
<string>r%   z8Empty 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 validN)r
   r2   r1   )r   ss1s2s   &   r   test_empty_line_after_linecont2SyntaxErrorTestCase.test_empty_line_after_linecont  s    	RAz6*

	IB
F+B
F+%  	RIIPQ	R&  	IIIGH	Is    2 A AAA43A4c                @    R pV P                  \        \        V4       R# )z(\
if x:
    y = 1
  \
  foo = 1
        N)assertRaisesrl   r%   r   r   s   & r   !test_continuation_bad_indentation5SyntaxErrorTestCase.test_continuation_bad_indentation  s     	*D$7r   c                    V P                  R R4       V P                  RR4       V P                  RR4       R
 F  p\        RV R2RRR7       K  	  R	# )zclass A[__classdict__]: passz?reserved name '__classdict__' cannot be used for type parameterzdef f[__classdict__](): passz,type T[__classdict__] = tuple[__classdict__]z
class A:
    class B[z]: pass
                r$   r%   rI   N)	__class____classcell__r+   )r?   r
   )r   names   & r    test_disallowed_type_param_names4SyntaxErrorTestCase.test_disallowed_type_param_names  st     	8Y	\8Y	\HY	\
 HD F  "0 Hr   c                    R p\        ^4       FC  pVRV,           R2,          pVRV^,           ,           R2,          pVRV,           R2,          pKE  	  VR R2,          pV P                  VR4       R# )	 z    ztry:
zraise Exception
zexcept Exception as e:
pass!too many statically nested blocksNz0                                                )ranger?   )r   r   is   &  r   test_nested_named_except_blocks3SyntaxErrorTestCase.test_nested_named_except_blocks  s~    rAvaxj''Dvqs|n$566Dvaxj 899D  	8*D!!$ CDr   c                   R  p^pV^,
          p\        V4       F<  pV P                  RV: 24      ;_uu_ 4        \        V! V4      RR4       RRR4       K>  	  \        W3^,           4       FA  pV P                  RV: 24      ;_uu_ 4        V P                  V! V4      R4       RRR4       KC  	  R#   + '       g   i     K  ; i  + '       g   i     Kl  ; i)c                     \         P                  ! R 4      p\        V 4       F  pVRV R2,          pK  	  VR,          pV# )z]
                def bug():
                    with (
                    a
                    as a, a

): yield a)r   r   r   nr   r   s   &  r   get_codeOSyntaxErrorTestCase.test_with_statement_many_context_managers.<locals>.get_code  sG    ?? $ D
 1X(1#U++ L DKr   within range: n=r   r%   Nout of range: n=r   r   subTestr
   r?   r   r   CO_MAXBLOCKSMAX_MANAGERSr   s   &    r   )test_with_statement_many_context_managers=SyntaxErrorTestCase.test_with_statement_many_context_managers  s    		 #a'|$A 1qd344Z8 54 % |A%56A 1qd344!!(1+/RS 54 7 544 544   B3C3CCc                   R  p^pV^,
          p\        V4       F<  pV P                  RV: 24      ;_uu_ 4        \        V! V4      RR4       RRR4       K>  	  \        W3^,           4       FA  pV P                  RV: 24      ;_uu_ 4        V P                  V! V4      R4       RRR4       KC  	  R#   + '       g   i     K  ; i  + '       g   i     Kl  ; i)c                     \         P                  ! R 4      .p\        V 4       F  pVP                  RV R24       K  	  VP                  R4       RP	                  V4      # )zi
                async def bug():
                    async with (
                    a
                r   r   r   r   )r   r   r   appendjoinr   s   &  r   r   USyntaxErrorTestCase.test_async_with_statement_many_context_managers.<locals>.get_code  sY    __ &  D
 1Xhqc/0 KK%774= r   r   r   r%   Nr   r   r   r   s   &    r   /test_async_with_statement_many_context_managersCSyntaxErrorTestCase.test_async_with_statement_many_context_managers  s    		! #a'|$A 1qd344Z8 54 % |A%56A 1qd344!!(1+/RS 54 7 544 544r   c                .    R pV P                  VR4       R# )zw
def func1():
    if a != b:
        raise ValueError

def func2():
    try
        return 1
    finally:
        pass
zexpected ':'NrB   r   s   & r   &test_barry_as_flufl_with_syntax_errors:SyntaxErrorTestCase.test_barry_as_flufl_with_syntax_errors  s    
 	$/r   c                    V P                  R R^^R7       V P                  RR^^R7       V P                  RR^^R7       R# )z	a = 3 \ 46unexpected character after line continuation character)r8   r9   z1,\#
2z
fgdfgf
1,\#
2
NrB   rC   s   &r   -test_invalid_line_continuation_error_positionASyntaxErrorTestCase.test_invalid_line_continuation_error_position  s^    ,R!"1 	 	. 	*R!"1 	 	. 	0R!"1 	 	.r   c                N    V P                  R R4       V P                  RR4       R# )u   A.Ɗ\ r   u   A.μ\
zunexpected EOF while parsingNrB   rC   s   &r   -test_invalid_line_continuation_left_recursiveASyntaxErrorTestCase.test_invalid_line_continuation_left_recursive  s+     	-R	T.8	:r   c                X   R  F   pV P                  VR,           RV R24       K"  	  R  F  pV P                  RV R2RV R24       K  	  R F   pV P                  VR,           RV R24       K"  	  R	pV P                  VR
4       V P                  RR4       RpV P                  VR4       R# )z([{z1 + 2\z' was never closedza = 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 '\['zmatch y:
 case e(e=v,v,z was never closeds.   # coding=latin
(aaaaaaaaaaaaaaaaa
aaaaaaaaaaaz'\(' was never closedNrB   )r   parenr   r   s   &   r   test_error_parenthesis*SyntaxErrorTestCase.test_error_parenthesis"  s    EegoE7:L/MN  EUG=9RwFX;YZ  EegougQ/GH  	$ \]46IJ C!56r   c                    V P                  R R4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  RR4       V P                  RR4       R	# )
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"""blechNrB   rC   s   &r   test_error_string_literal-SyntaxErrorTestCase.test_error_string_literal;  sr    ($JK($JKa	
 	b	
 	*&QR*&QRr   c                N    V P                  R R4       V P                  RR4       R# )zprint("Hello")zinvalid non-printable characters   with(0,,):
NrB   rC   s   &r   test_invisible_characters-SyntaxErrorTestCase.test_invisible_charactersH  s&    .0QR-/PQr   c                $    R p\        VRR4       R# )z)
def match(x):
    return 1+1

match(34)
r   r%   Nr
   r   s   & r   +test_match_call_does_not_raise_syntax_error?SyntaxErrorTestCase.test_match_call_does_not_raise_syntax_errorL       	j&)r   c                $    R p\        VRR4       R# )z'
def case(x):
    return 1+1

case(34)
r   r%   Nr   r   s   & r   *test_case_call_does_not_raise_syntax_error>SyntaxErrorTestCase.test_case_call_does_not_raise_syntax_errorU  r   r   c                .    V P                  R R^R7       R# )zcall(
a=1,
a=1
)zkeyword argument repeatedrT   NrB   rC   s   &r   /test_multiline_compiler_error_points_to_the_endCSyntaxErrorTestCase.test_multiline_compiler_error_points_to_the_end^  s    !' 	 	
r   c                .    R pV P                  VR4       R# )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   NrB   r   s   & r   )test_syntax_error_on_deeply_nested_blocks=SyntaxErrorTestCase.test_syntax_error_on_deeply_nested_blockse  s    2 	&"EFr   c           
     4   R R,          R,           pR FZ  pV P                  VR7      ;_uu_ 4        V P                  \        R4      ;_uu_ 4        \        VRV4       RRR4       RRR4       K\  	  R#   + '       g   i     L; i  + '       g   i     K  ; i)-i 4rI   ztoo complexr   N)r%   evalrH   )r   assertRaisesRegexMemoryErrorr
   )r   r   r   s   &  r   #test_error_on_parser_stack_overflow7SyntaxErrorTestCase.test_error_on_parser_stack_overflow  sk    v#.D4((++KHHFJ5 I )( /HH )((s#   BA3B3B>BBc                    R pV P                  \        4      ;_uu_ 4        \        VRR4       RRR4       R#   + '       g   i     R# ; i)z,d{{{{{{{{{{{{{{{{{{{{{{{{{```{{{{{{{ef f():yr   r%   N)r   r2   r
   r   s   & r   test_deep_invalid_rule*SyntaxErrorTestCase.test_deep_invalid_rule  s6    
 @{++FJ/ ,+++s	   8A		c                |    V P                  \        P                  ! R 4      R^^^^\        R4      ,           R7       R# )z
                try:
                    pass
                except ValueError as obj.attr:
                    pass
                z*cannot use except statement with attributeobj.attrr   r8   r:   r9   r;   Nr?   r   r   lenrC   s   &r    test_except_stmt_invalid_as_expr4SyntaxErrorTestCase.test_except_stmt_invalid_as_expr  sA    OO AC
O+ 	 	
r   c                |    V P                  \        P                  ! R 4      R^^^^\        R4      ,           R7       R# )zn
                match 1:
                    case x as obj.attr:
                        ...
                z&cannot use attribute as pattern targetr   r   Nr   rC   s   &r   test_match_stmt_invalid_as_expr3SyntaxErrorTestCase.test_match_stmt_invalid_as_expr  s@    OO =C
O+ 	 	
r   c                F    R pR F  pV P                  RV 2V4       K  	  R# )z8expected expression after 'else', but statement is givenzx = 1 if 1 else N)r   returnzreturn 2zraise Exception('a')zdel azyield 2zassert Falser   r   import
import astfromzfrom ast import *rB   r   rc   stmts   &  r   test_ifexp_else_stmt(SyntaxErrorTestCase.test_ifexp_else_stmt  s-    H
D  07=
r   c                H    R pR F  pV P                  RV R2V4       K  	  R# )7expected expression before 'if', but statement is givenx = z if 1 else 1N)r   r   r   rB   r   s   &  r   $test_ifexp_body_stmt_else_expression8SyntaxErrorTestCase.test_ifexp_body_stmt_else_expression  s.    G
D
 TF,7=
r   c                P    R pR F  w  r#V P                  RV RV 2V4       K  	  R# )r   r  z if 1 else N))r   r   )r   r   )r   r   rB   )r   rc   lhs_stmtrhs_stmts   &   r   test_ifexp_body_stmt_else_stmt2SyntaxErrorTestCase.test_ifexp_body_stmt_else_stmt  s5    G#
H
 XJk(DcJ#
r   r#   )r$   r%   NNNNN)4r&   r'   r(   r)   r?   rD   rJ   rN   rQ   rU   rX   r\   r_   rd   rg   rm   rp   rs   rv   ry   r|   r   r   r   r   r   r   cpython_onlyr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   skip_wasi_stack_overflowr   r   r   r   r  r  r*   r+   r,   s   @r   r/   r/   
  s    =<
B/:>DF..
)	)555
J8
8
L
J
J
I@
8 0 0$ E E T T2 T T20"	.:72SR**
 !G !GF 6 6 %%'0 ( 0
"
 >(>K Kr   r/   c                 N    VP                  \        P                  ! 4       4       V# r   )addTestdoctestDocTestSuite)loadertestspatterns   &&&r   
load_testsr    s    	MM'&&()Lr   __main__)r4   r  r   unittesttestr   TestCaser   r/   r  r&   mainr#   r   r   <module>r     sc   ZS 
    NG)) NGb[K(++ [Kz
 zMMO r   