
    0hh                         S SK r S SKrS SKrS SKJr  S SKJr  S SKJr  S r	\R                  " \R                  S5       " S S\R                  5      5       r\S	:X  a  \R                  " 5         gg)
    N)support)	os_helper)assert_python_okc                  l    / n [        S5       H  nU R                  U5        M     Sn Sn[        X5        g )Nr   zthis isz
an example)rangeappendprint)xiys      :/opt/python-3.13.8/usr/lib/python3.13/test/test_lltrace.pyexampler   	   s1    
A1X	 AA	!K    zlltrace requires Py_DEBUGc                   ,    \ rS rSrS rS rS rS rSrg)TestLLTrace   c                 j   [         R                  " U5      R                  5       n[        [        R
                  SSS9 nU R                  [        R                  [        R
                  5        UR                  U5        S S S 5        [        [        R
                  5      u  p4nU R                  US5        U R                  US5        UR                  S5      n[        R                  (       a6  [        S5        [        U5        [        S5        [        U5        [        5         U$ ! , (       d  f       N= f)Nwzutf-8)encodingr   r   z

--- code ---z
--- stdout ---)textwrapdedentstripopenr   TESTFN
addCleanupunlinkwriter   assertEqualdecoder   verboser	   )selfcodefdstatusstdoutstderrresults          r   run_codeTestLLTrace.run_code   s    t$**,)""C':bOOI,,i.>.>?HHTN ; "2)2B2B!C%#w'??$%$K$%&MG ;:s   A D$$
D2c                 j   U R                  S5      nU R                  SU5        U R                  SU5        U R                  SU5        U R                  SU5        U R                  SU5        U R                  SU5        U R                  SU5        U R                  S	U5        U R                  S
U5        g )Na  
            def dont_trace_1():
                a = "a"
                a = 10 * a
            def trace_me():
                for i in range(3):
                    +i
            def dont_trace_2():
                x = 42
                y = -x
            dont_trace_1()
            __lltrace__ = 1
            trace_me()
            del __lltrace__
            dont_trace_2()
        GET_ITERFOR_ITERCALL_INTRINSIC_1POP_TOP	BINARY_OPUNARY_NEGATIVEz'trace_me' in module '__main__'dont_trace_1z'dont_trace_2' in module)r(   assertInassertNotInr!   r%   s     r   test_lltraceTestLLTrace.test_lltrace&   s         	j&)j&)(&1i(f-)627@03V<r   c                    U R                  S5      nU R                  SU5        U R                  SU5        U R                  SU5        U R                  SU5        [        R                  " [        SS9 Vs0 s H  o"R
                  U_M     nnUR                  5        H  nUR                  S5      u  pVnU(       d  M   [        U5      nUR                  5       n[        U5      S	:X  a  Uu  p[        U	5      n	OUu  nS n	U R                  X5   R                  U5        U R                  X5   R                  U	5        M     g s  snf )
Nz
            from test import test_lltrace
            test_lltrace.__lltrace__ = 1
            test_lltrace.example()
        z''example' in module 'test.test_lltrace'
LOAD_CONSTr,   zthis is an exampleT)adaptive:   )r(   r2   disget_instructionsr   offset
splitlines	partitionintsplitlenr   opnamearg)
r!   r%   r   	instr_mapliner>   colonopname_opargrD   opargs
             r   test_lltrace_different_module)TestLLTrace.test_lltrace_different_moduleB   s!      
 	?HlF+j&)*F3 +.*>*>wQU*VW*VQXXq[*V	W%%'D*...*='F<[F'--/L< A% ,E
(	Y.55v>Y.22E: ( Xs   5D>c                 J    U R                  S5      nU R                  SU5        g )Nz
            import code

            console = code.InteractiveConsole()
            console.push('__lltrace__ = 1')
            console.push('a = [1, 2, 3]')
            console.push('a[0] = 1')
            print('unreachable if bug exists')
        zunreachable if bug exists)r(   r2   r4   s     r   1test_lltrace_does_not_crash_on_subscript_operator=TestLLTrace.test_lltrace_does_not_crash_on_subscript_operator^   s(    
     	16:r    N)	__name__
__module____qualname____firstlineno__r(   r5   rK   rN   __static_attributes__rP   r   r   r   r      s    "=8;8;r   r   __main__)r<   r   unittesttestr   test.supportr   test.support.script_helperr   r   
skipUnlessPy_DEBUGTestCaser   rQ   mainrP   r   r   <module>r_      sn    
    " 7 
W%%'BCY;(## Y; DY;v zMMO r   