+
    Bi5                        R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	 ^ RI
HtHtHtHtHt ^ RIHt ^ RIHt  ^ RIt]'       g   ]P,                  ! R4      hR]P.                  R	]P0                  /R
 ltR t]	P6                   ! R R]P8                  4      4       t]	P6                   ! R R]P8                  4      4       t ! R R]P8                  4      t] R8X  d   ]PB                  ! 4        R# R#   ] d    Rt Li ; i)z!Test the interactive interpreter.N)dedent)support)cpython_onlyhas_subprocess_support	os_helperSuppressCrashReportSHORT_TIMEOUT)kill_python)import_moduleztest module requires subprocessstdoutstderrc                   \         P                  P                  \         P                  P                  \        P
                  4      R4      pVRR.pVP                  V4       VP                  R\        \         P                  4      4      pRVR&   \        P                  ! V3R\        P
                  RR	R
\        P                  RV RV/VB # )z}Run the Python REPL with the given arguments.

kw is extra keyword args to pass to subprocess.Popen. Returns a Popen
object.
<stdin>-I-ienvvt100TERM
executabletextTstdinr   r   )ospathjoindirnamesysr   extend
setdefaultdictenviron
subprocessPopenPIPE)r   r   argskwstdin_fnamecmd_liner   s   $$*,   %/usr/lib/python3.14/test/test_repl.py
spawn_replr(      s     '',,rwws~~>	JKT4(HOOD --tBJJ/
0CCKH "'*~~"!%" #-//" $*	" 39	"
 !" "    c                    \        4       pVP                  P                  V 4       \        V4      pVP                  ^ 8w  d   \        R4      hV# )zSpawn a new Python interpreter, pass the given
input source code from the stdin and return the
result back. If the interpreter exits non-zero, it
raises a ValueError.zProcess didn't exit properly.)r(   r   writer	   
returncode
ValueError)sourceprocessoutputs   &  r'   run_on_interactive_moder1   :   sF     lGMM!FQ899Mr)   c                      a  ] tR t^It o ]]P                  ! ]P                  R4      R 4       4       t	]R 4       t
R tR tR tR tR tR	 tR
 t]P$                  ! ]R4      R 4       tRtV tR# )TestInteractiveInterpreterzcannot test Py_TRACE_REFS buildc                N   \        R 4       Rp\        V4      p\        4       p\        4       ;_uu_ 4        VP                  P                  V4       RRR4       \        V4      pV P                  RV4       V P                  VP                  R4       R#   + '       g   i     LK; i)	_testcapiz
            import sys, _testcapi
            1/0
            print('After the exception.')
            _testcapi.set_nomemory(0)
            sys.exit(0)
        NzAfter the exception.)   x   )	r
   r   r(   r   r   r+   r	   assertInr,   self
user_inputpr0   s   &   r'   test_no_memory)TestInteractiveInterpreter.test_no_memoryL   sw    
 	k"
 J'
L ""GGMM*% #Q,f5allH- #"s   BB$	c                    R p\        V4      p\        4       pVP                  P                  V4       \	        V4      pV P                  VP                  ^ 4       R# )a          x = """<?xml version="1.0" encoding="iso-8859-1"?>
        <test>
            <Users>
                <fun25>
                    <limits>
                        <total>0KiB</total>
                        <kbps>0</kbps>
                        <rps>1.3</rps>
                        <connections>0</connections>
                    </limits>
                    <usages>
                        <total>16738211KiB</total>
                        <kbps>237.15</kbps>
                        <rps>1.3</rps>
                        <connections>0</connections>
                    </usages>
                    <time_to_refresh>never</time_to_refresh>
                    <limit_exceeded_URL>none</limit_exceeded_URL>
                </fun25>
            </Users>
        </test>"""
        N)r   r(   r   r+   r	   assertEqualr,   r9   s   &   r'   test_multiline_string_parsing8TestInteractiveInterpreter.test_multiline_string_parsinge   sI    
. J'
L	j!Qq)r)   c                    \        R 4      p\        R4      p\        RV4      pVP                  V4      ^ ,          pV P                  VP                  ^ 4       V P                  RV4       R# )zY
            import os
            print("before close")
            os.close(0)
        zl
            from test.support import suppress_msvcrt_asserts
            suppress_msvcrt_asserts()
        z-czbefore closeN)r   r(   communicater@   r,   r8   )r:   r;   prepare_replr/   r0   s   &    r'   test_close_stdin+TestInteractiveInterpreter.test_close_stdin   si      

    T<0$$Z03++Q/nf-r)   c                    R p\        4       pVP                  P                  V4       \        V4      pV P	                  VP
                  ^ 4       VP                  4       RR p. ROpV P	                  WE4       R# )z1 / 0 / 3 / 4Ni)z"Traceback (most recent call last):%  File "<stdin>", line 1, in <module>z    1 / 0 / 3 / 4	    ~~^~~#ZeroDivisionError: division by zero)r(   r   r+   r	   r@   r,   
splitlines)r:   r;   r<   r0   traceback_linesexpected_liness   &     r'   $test_interactive_traceback_reporting?TestInteractiveInterpreter.test_interactive_traceback_reporting   sg    $
L	j!Qq) ++-b4
 	9r)   c                >   \        R 4      p\        4       pVP                  P                  V4       RpVP                  P                  V4       \	        V4      pV P                  VP                  ^ 4       VP                  4       RR p. ROpV P                  WV4       R# )z0
        def foo(x):
            1 / x

        zfoo(0)NirI   )rJ   z
    foo(0)z
    ~~~^^^z   File "<stdin>", line 2, in fooz	    1 / xrK   rL   )r   r(   r   r+   r	   r@   r,   rM   )r:   user_input1r<   user_input2r0   rN   rO   s   &      r'   3test_interactive_traceback_reporting_multiple_inputNTestInteractiveInterpreter.test_interactive_traceback_reporting_multiple_input   s      
 L	k"	k"Qq) ++-b4
 	9r)   c           	        R  p\         P                  ! 4       ;_uu_ 4       p\        P                  P	                  VR4      p\        VR4      ;_uu_ 4       pVP                  R\        P                  ,           4       RRR4       \        P                  P                  4       pW5R&   \        P                  P	                  VR4      VR&   V! V4      pVP                  P                  R4       \        V4      pRRR4       \        R	4      pV P                  R
X4       V P                  W4       \         P                  ! 4       ;_uu_ 4       p\        P                  P	                  VR4      p\        VR4      ;_uu_ 4       pVP                  R4       RRR4       \        P                  P                  4       pW5R&   \        P                  P	                  VR4      VR&   V! V4      pVP                  P                  R4       \        V4      pRRR4       \        R4      X,          pV P                  W4       R#   + '       g   i     EL; i  + '       g   i     EL_; i  + '       g   i     L; i  + '       g   i     Lp; i)c           
      B   \         P                  ! \        P                  P	                  \        P                  P                  \        P                  4      R 4      R.\        P                  R\         P                  \         P                  \         P                  V R7      # )r   r   T)r   r   r   r   r   r   )
r    r!   r   r   r   r   r   r   r"   STDOUT)r   s   &r'   	make_replPTestInteractiveInterpreter.test_pythonstartup_error_reporting.<locals>.make_repl   sa    ##bggoocnn=yI4P>> oo!!(( r)   pythonstartup.pywzprint('from pythonstartup')NPYTHONSTARTUPz.pythonhistPYTHON_HISTORYz1/0z
            Traceback (most recent call last):
              File "<stdin>", line 1, in <module>
                1/0
                ~^~
            ZeroDivisionError: division by zero
        zfrom pythonstartupzdef foo():
    1/0
zfoo()a  
            Traceback (most recent call last):
              File "<stdin>", line 1, in <module>
                foo()
                ~~~^^
              File "%s", line 2, in foo
                1/0
                ~^~
            ZeroDivisionError: division by zero
        )r   temp_dirr   r   r   openr+   linesepr   copyr   r	   r   r8   )	r:   rZ   tmpdirscriptfr   r<   r0   expecteds	   &        r'   "test_pythonstartup_error_reporting=TestInteractiveInterpreter.test_pythonstartup_error_reporting   s   		 !!VWW\\&*<=Ffc""a5

BC # **//#C#) $&GGLL$GC !#AGGMM%  ^F "    	*F3h' !!VWW\\&*<=Ffc""a/0 # **//#C#) $&GGLL$GC !#AGGMM'" ^F "  	 	 	 	h'S #"" "!!0 #" "!sI   5I'H:	=A;I5I5 I"	A;I5:I	II	"I2-I55J	c                    \        R 4      p\        4       pVP                  P                  V4       \	        V4      p. ROpV P                  VP                  4       ^R V4       R# )z-def f(x, x): ...
                            N)z    def f(x, x): ...z             ^z:SyntaxError: duplicate argument 'x' in function definitionrI   )r   r(   r   r+   r	   r@   rM   )r:   r;   r<   r0   rO   s   &    r'   )test_runsource_show_syntax_error_locationDTestInteractiveInterpreter.test_runsource_show_syntax_error_location   sZ       !
L	j!Q

 	**,Qr2NCr)   c                (   \        R 4      p\        4       pVP                  P                  V4       \        R4      pVP                  P                  V4       \	        V4      pV P                  VP                  ^ 4       RpV P                  WTV4       R# )zi
        def foo(x):
            return x + 1

        def bar(x):
            return foo(x) + 2
        zq
        import linecache
        print(linecache._interactive_cache[linecache._make_key(foo.__code__)])
        zD(30, None, ['def foo(x):\n', '    return x + 1\n', '\n'], '<stdin>')Nr   r(   r   r+   r	   r@   r,   r8   r:   r;   r<   rT   r0   rg   s   &     r'   'test_interactive_source_is_in_linecacheBTestInteractiveInterpreter.test_interactive_source_is_in_linecache
  s{      
 L	j!   	
k"Qq)dh1r)   c           
        \         P                  ! 4       ;_uu_ 4       p\        P                  P	                  VR 4      p\        VR4      ;_uu_ 4       pVP                  R\        P                  ,           4       VP                  R\        P                  ,           4       RRR4       \        P                  P                  4       p\        P                  P	                  VR4      VR&   W$R&   \        P                  ! \        P                  RR	.\        P                  \        P                  V\        R
7       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)r\   r]   zprint('pythonstartup done!')zexit(0)Nz.asyncio_historyr_   r^   -masyncio)r   r   r   timeout)r   r`   r   r   r   ra   r+   rb   r   rc   r    
check_callr   r   r"   r   )r:   rd   re   rf   r   s   &    r'   /test_asyncio_repl_reaches_python_startup_scriptJTestInteractiveInterpreter.test_asyncio_repl_reaches_python_startup_script  s    !!VWW\\&*<=Ffc""a6CD	BJJ./ # **//#C$&GGLL9K$LC !#) !!y1!!% "!"" "!!s%   5EAE	 BEEEE'	zrequires ptyc           
     t   \         P                  ! 4       w  r\        P                  R RR.p\        P
                  P                  4       p\        P                  ! VVVVRRVR7      p\        P                  ! V4       \        P                  ! VR4       \        P                  ! VR4       . p\        P                  ! V.. . \        4      ^ ,          '       dE    \        P                  ! VR4      P                  R4      pV'       g   M TP!                  T4       Ko  \        P                  ! V4        VP#                  \        R	7      pV P)                  V^ R
P+                  V4      4       R#   \         d     K_  i ; i  \        P$                   d$    TP'                  4        TP#                  4       p Lmi ; i)r   rs   rt   T)r   r   r   r   	close_fdsr   s   await asyncio.sleep(0)
s   exit()
i   zutf-8)ru    N)ptyopenptyr   r   r   r   rc   r    r!   closer+   selectr   readdecodeOSErrorappendwaitTimeoutExpiredkillr@   r   )	r:   mscmdr   procr0   data	exit_codes	   &        r'   test_asyncio_repl_is_ok2TestInteractiveInterpreter.test_asyncio_repl_is_ok0  sT   {{}~~tT95jjoo
 	
/0
K mmQCR7::wwq$'..w7  MM$
	$		-	8I
 	Arwwv7   (( 	$IIK		I	$s$   -E- 3E? -E<;E<?5F76F7 N)__name__
__module____qualname____firstlineno__r   unittestskipIfr   Py_TRACE_REFSr=   rA   rF   rP   rU   rh   rk   rp   rw   
skipUnlessr|   r   __static_attributes____classdictcell____classdict__s   @r'   r3   r3   I   s       __W**,MN. O .* * *@.:":2:(|D2($ n- 8 . 8r)   r3   c                   &   a  ] tR tRt o R tRtV tR# )TestInteractiveModeSyntaxErrorsiT  c                ~    \        \        R 4      4      pVP                  4       RR p. ROpV P                  W#4       R# )zJ        def f():
            print(0)
            return yield 42
        NrI   )z    return yield 42z           ^^^^^zSyntaxError: invalid syntax)r1   r   rM   r@   )r:   r0   rN   rO   s   &   r'   *test_interactive_syntax_error_correct_lineJTestInteractiveModeSyntaxErrors.test_interactive_syntax_error_correct_lineW  sF    ( 1 *  !++-b4

 	9r)   r   N)r   r   r   r   r   r   r   r   s   @r'   r   r   T  s     : :r)   r   c                   2   a  ] tR tRt o R tR tR tRtV tR# )TestAsyncioREPLig  c                    R p\        RR4      pVP                  P                  V4       \        V4      pV P	                  RV4       V P                  RV4       R# )z"1 / 0; print(f'afterwards: {1+1}')rs   rt   ZeroDivisionErrorzafterwards: 2N)r(   r   r+   r	   r8   assertNotInr9   s   &   r'   #test_multiple_statements_fail_early3TestAsyncioREPL.test_multiple_statements_fail_earlyh  sK    9
tY'	j!Q)62&1r)   c                ,   \        R 4      p\        RR4      pVP                  P                  V4       \        R4      pVP                  P                  V4       \	        V4      pV P                  VP                  ^ 4       RpV P                  WTV4       R# )z{        from contextvars import ContextVar
        var = ContextVar("var", default="failed")
        var.set("ok")
        rs   rt   zA
        print(f"toplevel contextvar test: {var.get()}")
        toplevel contextvar test: okNrn   ro   s   &     r'   test_toplevel_contextvars_sync.TestAsyncioREPL.test_toplevel_contextvars_syncp  s      

 tY'	j!   	
k"Qq)1h1r)   c                   \        R 4      p\        RR4      pVP                  P                  V4       RpVP                  P                  V4       RpVP                  P                  V4       RpVP                  P                  V4       \	        V4      pV P                  VP                  ^ 4       RpV P                  WvV4       R# )ze        from contextvars import ContextVar
        var = ContextVar('var', default='failed')
        rs   rt   z#async def set_var(): var.set('ok')
zawait set_var()
z0print(f'toplevel contextvar test: {var.get()}')
r   Nrn   )r:   r;   r<   rT   user_input3user_input4r0   rg   s   &       r'   test_toplevel_contextvars_async/TestAsyncioREPL.test_toplevel_contextvars_async  s      
 tY'	j!<	k")	k"I	k"Qq)1h1r)   r   N)	r   r   r   r   r   r   r   r   r   r   s   @r'   r   r   g  s     22"2 2r)   r   __main__)"__doc__r   r   r    r   r   textwrapr   testr   test.supportr   r   r   r   r   test.support.script_helperr	   test.support.import_helperr
   r|   ImportErrorSkipTestr"   rY   r(   r1   force_not_colorized_test_classTestCaser3   r   r   r   mainr   r)   r'   <module>r      s   ' 	   
     3 4
 


=
>>"Z__ "Z5F5F "8 	''G8!2!2 G8 (G8T 	'':h&7&7 : (:$*2h'' *2Z zMMO }  
Cs   C5 5	D D