HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/__pycache__/test_pdb.cpython-310.opt-2.pyc
o

�i��@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZmZddl
mZddlmZddlmZddlmZGdd�de�Zd	d
�Zdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z dd�Z!dd �Z"d!d"�Z#d#d$�Z$d%d&�Z%e�&d'�Z'e(d(e'j)�d)d*�Z*d+d,�Z+d-d.�Z,d/d0�Z-d1d2�Z.d3d4�Z/d5d6�Z0d7d8�Z1d9d:�Z2d;d<�Z3d=d>�Z4d?d@�Z5dAdB�Z6dCdD�Z7dEdF�Z8dGdH�Z9dIdJ�Z:dKdL�Z;GdMdN�dNej<�Z=GdOdP�dPej<�Z>dQdR�Z?e@dSkr�e�A�dSdS)T�N)�	ExitStack�redirect_stdout)�StringIO)�	os_helper)�
_FakeInput)�patchc@s&eZdZ	dd�Zdd�Zdd�ZdS)�PdbTestInputcCs
||_dS�N)�input)�selfr
�r�*/usr/local/lib/python3.10/test/test_pdb.py�__init__s
zPdbTestInput.__init__cCs6tj|_t|j�t_ttd�rt��|_dSd|_dS)N�gettrace)�sys�stdin�
real_stdinrr
�hasattrr�
orig_trace�rrrr
�	__enter__s"zPdbTestInput.__enter__cGs"|jt_|jrt�|j�dSdSr	)rrrr�settrace)r�excrrr
�__exit__!s�zPdbTestInput.__exit__N)�__name__�
__module__�__qualname__rrrrrrr
rs
rcC�dSr	rrrrr
�test_pdb_displayhook'�rcCrr	rrrrr
�test_pdb_basic_commandsDrr cCsddl}|j��dS)Nr)�bdbZ
BreakpointZclearBreakpoints)r!rrr
�reset_Breakpoint�sr"cCrr	rrrrr
�test_pdb_breakpoint_commands�rr#cCrr	rrrrr
�:test_pdb_breakpoints_preserved_across_interactive_sessionsGrr$cCrr	rrrrr
�test_pdb_pp_repr_exc�rr%cCrr	rrrrr
�
do_nothing�rr&cCstd�dS)N�*)�printrrrr
�do_something��r)cCrr	rrrrr
�test_list_commands�rr+cCrr	rrrrr
�test_pdb_whatis_commandrr,cCrr	rrrrr
�test_pdb_display_command5rr-cCrr	rrrrr
�test_pdb_alias_commandgrr.cCrr	rrrrr
�test_pdb_where_command�rr/cCrr	rrrrr
�test_post_mortem�rr0cCrr	rrrrr
�test_pdb_skip_modules	rr1Zmodule_to_skipz6def foo_pony(callback): x = 1; callback(); return NonecCrr	rrrrr
�#test_pdb_skip_modules_with_callback%rr2cCrr	rrrrr
� test_pdb_continue_in_bottomframePrr3cCs	ttjddd�|�|�dS)NTF)ZnosigintZreadrc)�getattr�pdb�Pdb)�method�argrrr
�
pdb_invokezsr9cCrr	rrrrr
�$test_pdb_run_with_incorrect_argumentrr:cCrr	rrrrr
�test_pdb_run_with_code_object�rr;cCrr	rrrrr
�&test_next_until_return_at_return_event�rr<cCrr	rrrrr
�#test_pdb_next_command_for_generator�rr=cCrr	rrrrr
�#test_pdb_next_command_for_coroutine rr>cCrr	rrrrr
�"test_pdb_next_command_for_asyncgenXrr?cCrr	rrrrr
�%test_pdb_return_command_for_generator�rr@cCrr	rrrrr
�%test_pdb_return_command_for_coroutine�rrAcCrr	rrrrr
�$test_pdb_until_command_for_generator�rrBcCrr	rrrrr
�$test_pdb_until_command_for_coroutine"rrCcCrr	rrrrr
�+test_pdb_next_command_in_generator_for_loopQrrDcCrr	rrrrr
�!test_pdb_next_command_subiterator{rrEcCrr	rrrrr
�test_pdb_issue_20766�rrFcCrr	rrrrr
�test_pdb_issue_43318�rrGcCrr	rrrrr
�test_pdb_issue_gh_101673�rrHc@s"eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!e"j#d?d@��Z$dAdB�Z%dCdD�Z&dES)F�PdbTestCasecC�t�tj�dSr	�r�unlink�TESTFNrrrr
�tearDown��zPdbTestCase.tearDowncCs�|�tjd�tjddg|}tj|tjtjtjit	j
�ddi�d��}|�t�
|��\}}Wd�n1s8wY|oCt�|�}|oJt�|�}||fS)N�__pycache__�-mr5�PYTHONIOENCODING�utf-8��stdoutr�stderr�env)�
addCleanupr�rmtreer�
executable�
subprocess�Popen�PIPE�STDOUT�os�environ�communicate�str�encode�bytes�decode)rZpdb_args�commands�cmd�procrUrVrrr
�_run_pdbs��zPdbTestCase._run_pdbcCs\	d}t|d��}|�t�|��Wd�n1swY|�tj|�|�|g|�S)N�main.py�w)�open�write�textwrap�dedentrXrrLri)r�scriptrf�filename�frrr
�run_pdb_scripts�zPdbTestCase.run_pdb_scriptcCs�	d|_t�|j�|jd}|jd}t�|j�t|d��}Wd�n1s*wYt|d��}|�t�|��Wd�n1sGwY|�	tj|j�|�
d|jg|�S)N�t_main�/__main__.py�/__init__.pyrkrQ)�module_namerrYr_�mkdirrlrmrnrorXri)rrprf�	main_file�	init_filerrrrr
�run_pdb_modules

��zPdbTestCase.run_pdb_modulecCslttjd��
}|�|�Wd�n1swY|sdn	|dtj|df}|�|t�|tj��dS)N�wbr�)rlrrMrm�assertEqualr5Z
find_function)rZfile_content�	func_name�expectedrrrrr
�_assert_find_function's���z!PdbTestCase._assert_find_functioncCs|�ddd�dS)N�Zfoo)r�rrrr
�test_find_function_empty_file0sz)PdbTestCase.test_find_function_empty_filecCs|�d��dd�dS)Nu@def foo():
    pass

def bœr():
    pass

def quux():
    pass
�bœr)r���r�rcrrrr
�test_find_function_found3s	�z$PdbTestCase.test_find_function_foundcCs|�d�d�dd�dS)NuV# coding: iso-8859-15
def foo():
    pass

def bœr():
    pass

def quux():
    pass
ziso-8859-15r�)r��r�rrrr
�-test_find_function_found_with_encoding_cookieCs
�z9PdbTestCase.test_find_function_found_with_encoding_cookiecCs|�tjd��dd�dS)Nudef bœr():
    pass
r�)r�r})r��codecs�BOM_UTF8rcrrrr
�!test_find_function_found_with_bomTs��z-PdbTestCase.test_find_function_found_with_bomcCs�ttjd��
}|�d�Wd�n1swYtjddtjg}tj|tjtjtj	d�}|�
|jj�|�
d�\}}|�d|d�dS)	Nr|sprint("testing my pdb")
rQr5�rUrrVsquit
sSyntaxErrorz0Got a syntax error running test script under PDB)rlrrMrmrrZr[r\r]r^rXrU�closera�assertNotIn�rrrrgrhrUrVrrr
�test_issue7964^s���zPdbTestCase.test_issue7964cCsHd}d}|�||�\}}|pd|pd}|�d|d�|�d|d�dS)Nz�
            def do_testcmdwithnodocs(self, arg):
                pass

            import pdb
            pdb.Pdb.do_testcmdwithnodocs = do_testcmdwithnodocs
        zA
            continue
            help testcmdwithnodocs
        ��AttributeErrorzCCalling help on a command with no docs should be handled gracefullyz;*** No help for 'testcmdwithnodocs'; __doc__ string missingz<Calling help on a command with no docs should print an error)rsr��assertIn)rrprfrUrV�outputrrr
�test_issue46434ms��zPdbTestCase.test_issue46434cCs�d}d}d}tdd��}|�t�|��Wd�n1swY|�tjd�|�||�\}}|�t	dd�|�
�D��d�dS)	Nz�
            from bar import bar

            def foo():
                bar()

            def nope():
                pass

            def foobar():
                foo()
                nope()

            foobar()
        z�
            from bar import bar
            break bar
            continue
            step
            step
            quit
        z5
            def bar():
                pass
        zbar.pyrkcs��|]}d|vVqdS)zmain.py(5)foo()->NoneNr��.0�lrrr
�	<genexpr>���z.PdbTestCase.test_issue13183.<locals>.<genexpr>z+Fail to step into the caller after a return)rlrmrnrorXrrLrs�
assertTrue�any�
splitlines)rrprfZbarrrrUrVrrr
�test_issue13183�s��zPdbTestCase.test_issue13183cC�ttjd��}|�t�d��d��Wd�n1swYtjdtjg}t	j
|t	jt	jt	jit
j�ddi�d�}|�|jj�|�d�\}}|�d	|d
�dS)Nr|a
                import threading
                import pdb

                def start_pdb():
                    pdb.Pdb(readrc=False).set_trace()
                    x = 1
                    y = 1

                t = threading.Thread(target=start_pdb)
                t.start()�ascii�-urRrSrTscont
�Error�*Got an error running test script under PDB�rlrrMrmrnrorcrrZr[r\r]r^r_r`rXrUr�rar�r�rrr
�test_issue13120�s"
����zPdbTestCase.test_issue13120cCr�)Nr|a�
                import threading
                import pdb

                evt = threading.Event()

                def start_pdb():
                    evt.wait()
                    pdb.Pdb(readrc=False).set_trace()

                t = threading.Thread(target=start_pdb)
                t.start()
                pdb.Pdb(readrc=False).set_trace()
                evt.set()
                t.join()r�r�rRrSrTs
cont
cont
r�r�r�r�rrr
�test_issue36250�s"����zPdbTestCase.test_issue36250cCs6d}d}d}|�||�\}}|�||d�||��dS)Nzdef f: pass
r�zSyntaxError:zE

Expected:
{}
Got:
{}
Fail to handle a syntax error in the debuggee.)rsr��format)rrprfr�rUrVrrr
�test_issue16180�s�zPdbTestCase.test_issue16180cCsLd}d}|�||�\}}d�dd�|��D��}|�|d�|�|d�dS)Nzprint('hello')z[
            continue
            run a b c
            run d e f
            quit
        �
cSsg|]}|���qSr)�strip)r��xrrr
�
<listcomp>�sz/PdbTestCase.test_issue26053.<locals>.<listcomp>z#Restarting .* with arguments:
a b cz#Restarting .* with arguments:
d e f)rs�joinr�ZassertRegex)rrprfrUrV�resrrr
�test_issue26053�szPdbTestCase.test_issue26053c	Cs:t�d�}tj�dd�}z�t���ltdd��
}|�d�Wd�n1s'wYtdd��
}|�|�Wd�n1sAwYt	j
dg}tj|tj
tj
tj
d�}|�|�d�\}}|�d	|�Wd�n1sqwYWd�n1s�wYW|dur�|tjd<dSdS|dur�|tjd<w)
Nz_
            import pdb; pdb.Pdb(readrc=False).set_trace()

            print('hello')
        �HOME�.pdbrcrkzinvalid
rjr�sq
s(NameError: name 'invalid' is not defined)rnror_r`�popr�temp_cwdrlrmrrZr[r\r]rar�)rrp�	save_homerrrgrhrUrVrrr
�test_readrc_kwarg�s<

��
�������zPdbTestCase.test_readrc_kwargcCstj�dd�}t���l}td��Otj�|d�}|tjj_	z0t
|d��
}|�d�Wd�n1s3wY|�t
��jdd�W|durM|tjd<n
|durW|tjd<wWd�n1sbwYWd�dSWd�dS1szwYdS)Nr�zos.path.expanduserr�rk�invalidr)r_r`r�r�temp_dirr�pathr��
expanduserZreturn_valuerlrmr~r5r6ZrcLines)rr�r�Zrc_pathrrrrr
�test_readrc_homedirs 
�
���P�zPdbTestCase.test_readrc_homedircCsxt�}d}t�� }|�td|��|�t�tjd��tj|d�Wd�n1s+wY|�|�	�|d�dS)Nz"Nobody expects... blah, blah, blahz
sys.stdout�	set_trace)�headerr�)
rr�
enter_contextr�objectr5r6r�r~�getvalue)rrUr�Z	resourcesrrr
�test_header&s�zPdbTestCase.test_headercC�:d}d}|�||�\}}|�tdd�|��D��|�dS)Nzprint("SUCCESS")�/
            continue
            quit
        csr���SUCCESSNrr�rrr
r�6r�z.PdbTestCase.test_run_module.<locals>.<genexpr>�r{r�r�r��rrprfrUrVrrr
�test_run_module/s"zPdbTestCase.test_run_modulecCr�)NzQ
            if __name__ == '__main__':
                print("SUCCESS")
        r�csr�r�rr�rrr
r�Br�z9PdbTestCase.test_module_is_run_as_main.<locals>.<genexpr>r�r�rrr
�test_module_is_run_as_main8s"z&PdbTestCase.test_module_is_run_as_maincCsXd}d}|�||�\}}|�tdd�|��D��|�|�tdd�|��D��|�dS)Nz{
            if __name__ == '__main__':
                pass
                print("SUCCESS")
                pass
        z*
            b 3
            quit
        csr�)zBreakpoint 1 atNrr�rrr
r�Pr�z.PdbTestCase.test_breakpoint.<locals>.<genexpr>css�|]}d|vVqdSr�rr�rrr
r�Qr�)r{r�r�r��allr�rrr
�test_breakpointDs
"zPdbTestCase.test_breakpointcCs2d}|�ddg|�\}}|�tj|�dd��dS)Nz(
            c
            quit
        rQr5�
r�)rir�r5Z_usage�replace)rrfrUrVrrr
�test_run_pdb_with_pdbSs
�z!PdbTestCase.test_run_pdb_with_pdbcCs�d}t�|�|d}t�|�t|d��Wd�n1s wY|�tj|�|�d|gd�\}}|�d|���dS)NrtrvrkrQr�z,ImportError: No module named t_main.__main__)	rrYr_rxrlrXrir�r�)rrwrzrUrVrrr
�test_module_without_a_main^s

��z&PdbTestCase.test_module_without_a_maincCs�d}d}t�|�|d|}t�|�t|dd��Wd�n1s&wY|�tj|�|�d|�dd�gd�\}}|�d	|�dS)
NZt_pkgrt�/rvrkrQ�.r�z;'t_pkg.t_main' is a package and cannot be directly executed)	rrYr_�makedirsrlrXrir�r�)rZpkg_namerw�modpathrUrVrrr
�test_package_without_a_mainjs

��z'PdbTestCase.test_package_without_a_maincCr�)NzY
                #This is a comment, on line 2

                print("SUCCESS")
        z
            quit
        csr�)z__main__.py(4)<module>()Nrr�rrr
r��s���z=PdbTestCase.test_blocks_at_first_code_line.<locals>.<genexpr>r�r�rrr
�test_blocks_at_first_code_linexs��z*PdbTestCase.test_blocks_at_first_code_linecCsnd|_t�|j�|jd}|jd}|jd}|�tj|j�t�|j�t|d��}|�t�	d��Wd�n1s>wYt|d��}|�t�	d��Wd�n1s[wYt|d��}|�t�	d��Wd�n1sxwYd	}|�
d
|jg|�\}}|�tdd�|�
�D��|�|�td
d�|�
�D���|�tdd�|�
�D���dS)Nrtrurv�
/module.pyrk�6
                top_var = "VAR from top"
            z�
                from . import top_var
                from .module import var
                from . import module
                pass # We'll stop here and print the vars
            zY
                var = "VAR from module"
                var2 = "second var"
            zz
            b 5
            c
            p top_var
            p var
            p module.var2
            quit
        rQcsr��zVAR from moduleNrr�rrr
r��r�z4PdbTestCase.test_relative_imports.<locals>.<genexpr>csr�)zVAR from topNrr�rrr
r��r�csr�)z
second varNrr�rrr
r��r��rwrrYrXr_rxrlrmrnrorir�r�r��rryrzZmodule_filerrrfrU�_rrr
�test_relative_imports�s*


��� z!PdbTestCase.test_relative_importscCs:d|_t�|j�|jd}|jd}|jd}|�tj|j�t�|j�t|d��}|�t�	d��Wd�n1s>wYt|d��}|�t�	d��Wd�n1s[wYt|d��}|�t�	d��Wd�n1sxwYd	}|�
d
|jdg|�\}}|�tdd
�|�
�D��|�dS)Nrtz	/runme.pyrvr�rkr�zl
                from . import module
                pass # We'll stop here and print the vars
            z5
                var = "VAR from module"
            zQ
            b 3
            c
            p module.var
            quit
        rQz.runmecsr�r�rr�rrr
r��r�zDPdbTestCase.test_relative_imports_on_plain_module.<locals>.<genexpr>r�r�rrr
�%test_relative_imports_on_plain_module�s&


���"z1PdbTestCase.test_relative_imports_on_plain_modulecCsBd�gd��}|�d|d�\}}|�|��dd�gd��dS)Nr�)zprint(zdebug print(zdebug doesnotexist�c�passr})
�-> passz+(Pdb) *** SyntaxError: '(' was never closed�!(Pdb) ENTERING RECURSIVE DEBUGGERz%*** SyntaxError: '(' was never closed�LEAVING RECURSIVE DEBUGGERr�z> <string>(1)<module>()z9((Pdb)) *** NameError: name 'doesnotexist' is not definedr��(Pdb) �r�rsr~r�)rrfrUr�rrr
�test_errors_in_command�s z"PdbTestCase.test_errors_in_commandcs&	�fdd�}|dd�|dd�dS)NcsVd�d|��dg�}��d|d�\}}��|��dd�dd|�d|��d	g�dS)
Nr�zrun �qr�r}r�z(Pdb) *** Cannot run z: r�r�)Zbad_arg�msgrfrUr�rrr
�check�s�
�z*PdbTestCase.test_issue34266.<locals>.check�\zNo escaped character�"zNo closing quotationr)rr�rrr
�test_issue34266�s
zPdbTestCase.test_issue34266cCs|	t�d�}d}t���(}dtj�|���}|�||�\}}|�|�	d�d�
d�|�Wd�dS1s7wYdS)N�Q
            import sys
            print('sys.path[0] is', sys.path[0])
        �c
q�(Pdb) sys.path[0] is r��r�)rnrorr�r_r��realpathrsr~�split�rstrip)rrprf�cwdr�rUrVrrr
�test_issue42384�s

"�zPdbTestCase.test_issue42384c
	Cs	t�d�}d}t���w}tj�|�}tj�|d�}tj�|d�}d|��}t�|�t	tj�|d�d��
}|�
|�Wd�n1sEwYt�|�t�tj�|d�tj�|d��|�tj�dd�g|�\}}	|�
|�d�d	�d
�|�Wd�dS1s�wYdS)Nr�r��dir_one�dir_twor��foo.pyrkr�r�r�)rnrorr�r_r�r�r�rxrlrm�symlinkrir~r�r�)
rrprfr�r�r�r�rrrUrVrrr
�test_issue42384_symlinks"



�
 "�z#PdbTestCase.test_issue42384_symlinkc		Cst���x}tdd��}t�d�}|�|�Wd�n1swYtj�|d�}t�	|�t�	tj�|d��tj�|d�}t|d��
}|�d�Wd�n1sVwY|�
dgd�\}}d}|�|�d�d	�
d
�|�Wd�dS1swYdS)Nr�rkz�
                    print('The correct file was executed')

                    import os
                    os.chdir("subdir")
                �subdirz$print("The wrong file was executed")zc
c
qz#(Pdb) The correct file was executedr��r�)rr�rlrnrormr_r�r�rxrir~r�r�)	rr�rr�sr�Z
wrong_filerUrVr�rrr
�test_issue42383s 

�	
�"�zPdbTestCase.test_issue42383cCs�d}d}d}tdd��}|�t�|��Wd�n1swYtdd��}|�t�|��Wd�n1s;wY|�tjd�|�tjd�|�dg|�\}}|�d|d�dS)	Nza
        def func():
            x = "Sentinel string for gh-93696"
            print(x)
        aL
        import os
        import sys

        def _create_fake_frozen_module():
            with open('gh93696.py') as f:
                src = f.read()

            # this function has a co_filename as if it were in a frozen module
            dummy_mod = compile(src, "<frozen gh93696>", "exec")
            func_code = dummy_mod.co_consts[0]

            mod = type(sys)("gh93696")
            mod.func = type(lambda: None)(func_code, mod.__dict__)
            mod.__file__ = 'gh93696.py'

            return mod

        mod = _create_fake_frozen_module()
        mod.func()
        zf
            break 20
            continue
            step
            list
            quit
        z
gh93696.pyrkzgh93696_host.pyz"x = "Sentinel string for gh-93696"zSentinel statement not found)	rlrmrnrorXrrLrir�)rZ
frozen_srcZhost_programrfrrrUrVrrr
�test_gh_93696_frozen_list1s��z%PdbTestCase.test_gh_93696_frozen_listN)'rrrrNrirsr{r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rZskip_unless_symlinkr�r�r�rrrr
rI�sH	
$ 
		
%
rIc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�ChecklineTestscCst��dSr	)�	linecache�
clearcacherrrr
�setUp`r*zChecklineTests.setUpcCrJr	rKrrrr
rNcrOzChecklineTests.tearDowncCsXttjd��
}|�d�Wd�n1swYt��}|�|�tjd�d�dS�Nrkz
print(123)r})rlrrMrmr5r6r~�	checkline�rrr�dbrrr
�test_checkline_before_debuggingfs
�z.ChecklineTests.test_checkline_before_debuggingcCs`ttjd��
}|�d�Wd�n1swYt��}|��|�|�tjd�d�dSr)	rlrrMrmr5r6�resetr~rrrrr
�test_checkline_after_resetls�z)ChecklineTests.test_checkline_after_resetcCs�t�d�}ttjd��
}|�|�Wd�n1swYt|���d}tt	���t
��}t|�D]}|�
|�tj|��q6Wd�dS1sNwYdS)Nz\
            # Comment
            """ docstring """
            ''' docstring '''

        rkr�)rnrorlrrMrm�lenr�rrr5r6�rangeZassertFalser)rr�rrZ	num_linesr�linenorrr
� test_checkline_is_not_executabless
��"�z/ChecklineTests.test_checkline_is_not_executableN)rrrrrNrr
rrrrr
r_srcGs2ddlm}t�t�t�t�t�|�g}t�|�S)Nr)�test_pdb)	�testr�unittestZ	makeSuiterIr�doctestZDocTestSuiteZ	TestSuite)�argsrZsuitesrrr
�
load_tests�s�
r�__main__)Brr_r5r�typesr�rr[rnr�
contextlibrr�iorZtest.supportrZtest.test_doctestrZ
unittest.mockrr�rrr r"r#r$r%r&r)r+r,r-r.r/r0r1�
ModuleType�mod�exec�__dict__r2r3r9r:r;r<r=r>r?r@rArBrCrDrErFrGrHZTestCaserIrrr�mainrrrr
�<module>s|jC_*2);>
+*@;8=7*,/*/e%
�