;SrSSKrSSKrSSKrSSKrSSKrSSKJr SSKJ r SSK J r J r J r JrJr SSKJr SSKJr SSKr\ (d\R,"S5e\R.\R0S .S jrS r\ R6"S S \R855r\ R6"SS\R855r"SS\R85r\ S:Xa\RB"5 gg!\a SrNf=f)z!Test the interactive interpreter.N)dedent)support) cpython_onlyhas_subprocess_support os_helperSuppressCrashReport SHORT_TIMEOUT) kill_python) import_moduleztest module requires subprocess)stdoutstderrc [RR[RR[R 5S5nUSS/nUR U5 URS[[R55nSUS'[R"U4[R S[RXS.UD6$) z}Run the Python REPL with the given arguments. kw is extra keyword args to pass to subprocess.Popen. Returns a Popen object. z-Iz-ienvvt100TERMT) executabletextstdinr r ) ospathjoindirnamesysrextend setdefaultdictenviron subprocessPopenPIPE)r r argskw stdin_fnamecmd_liners 5/opt/alt/python313/lib64/python3.13/test/test_repl.py spawn_replr's'',,rwws~~> JKT4(H OOD --tBJJ/ 0CCK   H "'*~~!%",//#)  " !  ""c[5nURRU5 [U5nURS:wa [ S5eU$)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.rzProcess didn't exit properly.)r'rwriter returncode ValueError)sourceprocessoutputs r&run_on_interactive_moder0:sF lG MM  !FQ899 Mr(c\rSrSr\\R "\RS5S55r \S5r Sr Sr Sr SrS rS r\R""\S 5S 5rS rg)TestInteractiveInterpreterIzcannot test Py_TRACE_REFS buildc8[S5 Sn[U5n[5n[5 URR U5 SSS5 [ U5nURSU5 URURS5 g!,(df  NH=f)N _testcapiz import sys, _testcapi 1/0 print('After the exception.') _testcapi.set_nomemory(0) sys.exit(0) zAfter the exception.)x) r rr'rrr*r assertInr+self user_inputpr/s r&test_no_memory)TestInteractiveInterpreter.test_no_memoryLst k" J' L " GGMM* %#Q ,f5 allH- # "s B  BcSn[U5n[5nURRU5 [ U5nUR UR S5 g)Na x = """ 0KiB 0 1.3 0 16738211KiB 237.15 1.3 0 never none """ r)rr'rr*r assertEqualr+r9s r&test_multiline_string_parsing8TestInteractiveInterpreter.test_multiline_string_parsingesI .J' L  j!Q q)r(c[S5n[S5n[SU5nURU5SnURURS5 UR SU5 g)NzY import os print("before close") os.close(0) zl from test.support import suppress_msvcrt_asserts suppress_msvcrt_asserts() z-crz before close)rr' communicater@r+r8)r:r; prepare_replr.r/s r&test_close_stdin+TestInteractiveInterpreter.test_close_stdinsi    T<0$$Z03 ++Q/ nf-r(cSn[5nURRU5 [U5nUR UR S5 UR 5SSn/SQnUR XE5 g)Nz 1 / 0 / 3 / 4ri)z"Traceback (most recent call last):% File "", line 1, in z 1 / 0 / 3 / 4 ~~^~~#ZeroDivisionError: division by zero)r'rr*r r@r+ splitlines)r:r;r<r/traceback_linesexpected_liness r&$test_interactive_traceback_reporting?TestInteractiveInterpreter.test_interactive_traceback_reportingsg$ L  j!Q q) ++-b4  9r(c<[S5n[5nURRU5 SnURRU5 [ U5nUR UR S5 UR5SSn/SQnUR XV5 g)Nz0 def foo(x): 1 / x zfoo(0)rirI)rJz foo(0)z ~~~^^^z File "", line 2, in fooz 1 / xrKrL)rr'rr*r r@r+rM)r: user_input1r< user_input2r/rNrOs r&3test_interactive_traceback_reporting_multiple_inputNTestInteractiveInterpreter.test_interactive_traceback_reporting_multiple_inputs  L  k"   k"Q q) ++-b4  9r(c[S5n[5nURRU5 [ U5n/SQnUR UR 5SSU5 g)Nz-def f(x, x): ... )z def f(x, x): ...z ^z:SyntaxError: duplicate argument 'x' in function definitionrI)rr'rr*r r@rM)r:r;r<r/rOs r&)test_runsource_show_syntax_error_locationDTestInteractiveInterpreter.test_runsource_show_syntax_error_locationsZ ! L  j!Q  **,Qr2NCr(c&[S5n[5nURRU5 [S5nURRU5 [ U5nUR UR S5 SnURXTU5 g)Nzi 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__)]) rzD(30, None, ['def foo(x):\n', ' return x + 1\n', '\n'], '')rr'rr*r r@r+r8r:r;r<rTr/expecteds r&'test_interactive_source_is_in_linecacheBTestInteractiveInterpreter.test_interactive_source_is_in_linecaches{   L  j!    k"Q q)d h1r(c [R"5n[RR US5n[ US5nUR S[R-5 UR S[R-5 SSS5 [RR5n[RR US5US'X$S'[R"[RSS /[R[RU[S 9 SSS5 g!,(df  N=f!,(df  g=f) Nzpythonstartup.pywzprint('pythonstartup done!')zexit(0)z.asyncio_historyPYTHON_HISTORY PYTHONSTARTUP-masyncio)r r rtimeout)rtemp_dirrrropenr*lineseprcopyr check_callrrr!r )r:tmpdirscriptfrs r&/test_asyncio_repl_reaches_python_startup_scriptJTestInteractiveInterpreter.test_asyncio_repl_reaches_python_startup_scripts    !VWW\\&*<=Ffc"a6CD BJJ./#**//#C$&GGLL9K$LC !#)  ! !y1!!%  " !""" !s%-D8AD'BD8' D5 1D88 Ez requires ptyc [R"5up[RSSS/n[R R 5n[R"UUUUSSUS9n[R"U5 [R"US5 [R"US5 /n[R"U///[5S(ai[R"US 5RS 5nU(dO:UR!U5 [R"U///[5S(aMi[R"U5 UR#[S 9nUR)USS R+U55 g![a MZf=f![R$a# UR'5 UR#5nNjf=f) NrrerfT)rr r r close_fdsrsawait asyncio.sleep(0) sexit() rizutf-8)rg)ptyopenptyrrrrrkrr closer*selectr readdecodeOSErrorappendwaitTimeoutExpiredkillr@r) r:mscmdrprocr/data exit_codes r&test_asyncio_repl_is_ok2TestInteractiveInterpreter.test_asyncio_repl_is_oksq{{}~~tT95jjoo     /0 K mmQCR7: wwq$'..w7 MM$ mmQCR7::   $ - 8I Arwwv7   (( $ IIK I $s$-FF FF4G GN)__name__ __module__ __qualname____firstlineno__runittestskipIfr Py_TRACE_REFSr=rArFrPrUrYr_rp skipUnlessrur__static_attributes__rr(r&r2r2Is__W**,MN.O.***@ .:":2 D2($n- 8. 8r(r2c\rSrSrSrSrg)TestInteractiveModeSyntaxErrorsic|[[S55nUR5SSn/SQnURX#5 g)NzJ def f(): print(0) return yield 42 rI)z return yield 42z ^^^^^zSyntaxError: invalid syntax)r0rrMr@)r:r/rNrOs r&*test_interactive_syntax_error_correct_lineJTestInteractiveModeSyntaxErrors.test_interactive_syntax_error_correct_linesF(1 *  !++-b4  9r(rN)rrrrrrrr(r&rrs :r(rc&\rSrSrSrSrSrSrg)TestAsyncioREPLi)cSn[SS5nURRU5 [U5nUR SU5 UR SU5 g)Nz"1 / 0; print(f'afterwards: {1+1}')rerfZeroDivisionErrorz afterwards: 2)r'rr*r r8 assertNotInr9s r&#test_multiple_statements_fail_early3TestAsyncioREPL.test_multiple_statements_fail_early*sK9 tY '  j!Q )62 &1r(c*[S5n[SS5nURRU5 [S5nURRU5 [ U5nUR UR S5 SnURXTU5 g)Nz{ from contextvars import ContextVar var = ContextVar("var", default="failed") var.set("ok") rerfzA print(f"toplevel contextvar test: {var.get()}") rtoplevel contextvar test: okr\r]s r&test_toplevel_contextvars_sync.TestAsyncioREPL.test_toplevel_contextvars_sync2s  tY '  j!    k"Q q)1 h1r(c[S5n[SS5nURRU5 SnURRU5 SnURRU5 SnURRU5 [ U5nUR UR S5 SnURXvU5 g) Nze from contextvars import ContextVar var = ContextVar('var', default='failed') rerfz#async def set_var(): var.set('ok') zawait set_var() z0print(f'toplevel contextvar test: {var.get()}') rrr\)r:r;r<rT user_input3 user_input4r/r^s r&test_toplevel_contextvars_async/TestAsyncioREPL.test_toplevel_contextvars_asyncCs   tY '  j!<   k")   k"I   k"Q q)1 h1r(rN)rrrrrrrrrr(r&rr)s22"2r(r__main__)"__doc__rrxrrrtextwraprtestr test.supportrrrrr test.support.script_helperr test.support.import_helperr ru ImportErrorSkipTestr!STDOUTr'r0force_not_colorized_test_classTestCaser2rrrmainrr(r&rs'  34    = >>(__Z5F5F"8  ''I8!2!2I8(I8X '':h&7&7:(:$*2h''*2Z z MMOA  CsC00C;:C;