Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.10/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.10/test/__pycache__/test_sys.cpython-310.pyc
o

�9jB��@s*ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
ZddlmZddl
m
Z
ddlmZmZddl
mZddlZddlZddlZdaGdd�dej�ZGdd	�d	ej�ZGd
d�dej�ZejjGdd
�d
ej��ZejjGdd�dej��Zedkr�e��dSdS)�N)�support)�	os_helper)�assert_python_ok�assert_python_failure)�threading_helperc@�$eZdZdd�Zdd�Zdd�ZdS)�DisplayHookTestcCs�tj}t���}|d�Wd�n1swY|�|��d�|�tjd�t`t���}|d�Wd�n1s?wY|�|��d�|�t	td��|�
t|�tj}zt`|�
t
|d�W|t_dS|t_w)N�*z42
��_)�sys�__displayhook__r�captured_stdout�assertEqual�getvalue�builtinsr�
assertTrue�hasattr�assertRaises�	TypeError�stdout�RuntimeError)�self�dh�outr�r�$/usr/lib/python3.10/test/test_sys.py�test_original_displayhooks$

�

�z)DisplayHookTest.test_original_displayhookcCs:tj}zt`tddd�}|�tt|�W|t_dS|t_w)N�42�<string>�single)r�displayhook�compilerr�eval)rr!�coderrr�test_lost_displayhook7sz%DisplayHookTest.test_lost_displayhookcCsVdd�}t�td|��tddd�}|�tt|�Wd�dS1s$wYdS)NcS�t��N��
ValueError)�objrrr�baddisplayhookA�z?DisplayHookTest.test_custom_displayhook.<locals>.baddisplayhookr!rrr )r�	swap_attrrr"rr)r#)rr+r$rrr�test_custom_displayhook@s
"�z'DisplayHookTest.test_custom_displayhookN)�__name__�
__module__�__qualname__rr%r.rrrrrs	rc@r)�ExceptHookTestcCs�ztd��ty1}z!t���}tjt���Wd�n1s"wYWYd}~nd}~ww|�|���d��|�	t
tj�dS)Nr	�ValueError: 42
)r)r�captured_stderrr�__excepthook__�exc_inforr�endswithrr�r�exc�errrrr�test_original_excepthookKs
���z'ExceptHookTest.test_original_excepthookcCs�t���At�dt�ztdd��ty=}z!t���}tjt�	��Wd�n1s.wYWYd}~nd}~wwWd�n1sHwY|�
�}|�d|�|�d|�|�|�
d��dS)N�ignore�msg)sbytes_filename�{r�textz%  File "b'bytes_filename'", line 123
z	    text
zSyntaxError: msg
)�warnings�catch_warnings�simplefilter�BytesWarning�SyntaxErrorrr4rr5r6r�assertInrr7r8rrr�test_excepthook_bytes_filenameVs 


�����	z-ExceptHookTest.test_excepthook_bytes_filenamecCsPtj�d��}t�ddd�Wd�n1swY|�d|��v�dS)N�stderr��1zETypeError: print_exception(): Exception expected for value, str found)�testr�captured_outputr�
excepthookrr)rrGrrr�test_excepthookgs�
�zExceptHookTest.test_excepthookN)r/r0r1r;rFrMrrrrr2Isr2c@s(eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Ze	j
jd
d��Zdd�Z
dd�Ze�eed�d�dd��Ze	j
jdd��Zdd�Zejdd��Zejdd��Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Z d+d,�Z!d-d.�Z"d/d0�Z#e	j
jd1d2��Z$d3d4�Z%e�e&j'd5�e�e�(�e)�*d6�kd7�d8d9���Z+e�,ej-ej.kd:�d;d<��Z/dhd>d?�Z0d@dA�Z1didBdC�Z2dDdE�Z3dFdG�Z4dHdI�Z5dJdK�Z6e	j
jdLdM��Z7e�eedN�dO�dPdQ��Z8dRdS�Z9dTdU�Z:dVdW�Z;e�eedX�dY�dZd[��Z<d\d]�Z=d^d_�Z>e�eed`�da�dbdc��Z?ddde�Z@dfdg�ZAd=S)j�
SysModuleTestcCstj��dSr')rJr�
reap_children�rrrr�tearDowns�zSysModuleTest.tearDowncs���ttjdd���t��}t��Wd�n1swY��|jj�tdd�\}}}��	|d���	|d���	|d���t��
}t�d�Wd�n1sXwY��	|jjd���t��
}t�d�Wd�n1szwY��	|jjd���t��
}t�d�Wd�n1s�wY��	|jjd���t��
}t�d�Wd�n1s�wY��	|jjd�t
dd	�\}}}��	|d
���	|d���	|d��fdd�}|d
d�|dd�|dddd�dS)Nr	�-czimport sys; sys.exit()r�)r	�exit)��zraise SystemExit(47)�/csVtd|fi|��\}}}��|d���|d���|�|�dt|�t|�f�dS)NrSrHrTz%s doesn't start with %s)rrr�
startswith�ascii)r$�expected�env_vars�rcrr:rPrr�check_exit_message�s�z3SysModuleTest.test_exit.<locals>.check_exit_messagez?import sys; sys.stderr.write("unflushed,"); sys.exit("message")sunflushed,messagez)import sys; sys.exit("surrogates:\uDCFF")ssurrogates:\udcffzimport sys; sys.exit("h\xe9")sh�zlatin-1)�PYTHONIOENCODING)rrrrU�
SystemExit�assertIsNone�	exceptionr$rrr)r�cmr]rr:r^rrPr�	test_exitvsT
�����	��
�zSysModuleTest.test_exitcCs$|�ttjd�|�t��t�dS)Nr	)rrr�getdefaultencoding�assertIsInstance�strrPrrr�test_getdefaultencoding�sz%SysModuleTest.test_getdefaultencodingc	Cs�|�ttj�|�ttjd�|�ttjd�|�ttjd�t��}|�|dk|�zddd|fD]}t�|�|�t��|�q2Wt�|�dSt�|�w)N�ag�gg�?g�h㈵��>g�������?g@)rrr�setswitchintervalr)�getswitchintervalr�assertAlmostEqual)r�orig�nrrr�test_switchinterval�s
�z!SysModuleTest.test_switchintervalcCs^|�ttjd�t��}|�ttj�|�ttjd�t�d�|�t��d�t�|�dS)Nr	i���i')rrr�getrecursionlimit�setrecursionlimitr)r)r�oldlimitrrr�test_recursionlimit�s
z!SysModuleTest.test_recursionlimitc	s�ttd�rt��r|�d�t��}�fdd��zNdD]C}zt�|�Wn	ty-Yqw|�t����Wd�n1sAwY|�t����Wd�n1sYwYqWt�|�dSt�|�w)N�gettracez(fatal error if run with a trace functionc�
��dSr'rr��frrrw��
z5SysModuleTest.test_recursionlimit_recovery.<locals>.f)�2�K�d���)rrrt�skipTestrprq�RecursionErrorr)rrr�depthrrvr�test_recursionlimit_recovery�s(
�����z*SysModuleTest.test_recursionlimit_recoveryc	s`ddlm����fdd��t��}zt�d�dD]}�||�qWt�|�dSt�|�w)Nr)�get_recursion_depthcsf��}||kr,��t��
}t�|�Wd�n1swY��t|j�d�dS�||�dS)Nz\cannot set the recursion limit to [0-9]+ at the recursion depth [0-9]+: the limit is too low)rrrrq�assertRegexrgrb)r��limit�recursion_depthrc�r�r�set_recursion_limit_at_depthrrr��s��zZSysModuleTest.test_setrecursionlimit_recursion_depth.<locals>.set_recursion_limit_at_depthr})�
�ryrzr{���)�_testinternalcapir�rrprq)rrrr�rr�r�&test_setrecursionlimit_recursion_depth�s
�z4SysModuleTest.test_setrecursionlimit_recursion_depthcCsvtj�td�t��}|�t|�d�|�|dt�|�|dt�|�|dt�|�|dt�|�|dt	�|�
ttj
|d�|�|jt�|�|jt�|�|jt�|�|jt�|�|jt	�|�|jt�|�|jt�|�|jt�|�|jt�|�|d|j�|�|d|j�|�|d|j�|�|d|j�|�|d|j�t��\}}}}}dS)N�getwindowsversion�rrH���)rJr�
get_attributerr�r�lenrf�intrgr�
IndexError�operator�getitem�major�minor�build�platform�service_pack�service_pack_minor�service_pack_major�
suite_mask�product_type)r�v�maj�min�buildno�plat�csdrrr�test_getwindowsversion
s0z$SysModuleTest.test_getwindowsversioncCs|�ttjtd�dS)Nr�)rrr�call_tracing�typerPrrr�test_call_tracing+�zSysModuleTest.test_call_tracing�setdlopenflagsztest needs sys.setdlopenflags()cCsf|�ttd��|�ttjd�t��}|�ttj�t�|d�|�t��|d�t�|�dS)N�getdlopenflagsr	rH)rrrrrr�r�r)r�oldflagsrrr�test_dlopenflags.szSysModuleTest.test_dlopenflagscCsh|�ttj�t�d�}da|�t�d�|d�b|�t�d�|�ttd�r2|�t��t	�dSdS)NrH�gettotalrefcount)
rrr�getrefcountrnrrrfr�r�)r�crrr�
test_refcount9s

�zSysModuleTest.test_refcountcCs>|�ttjdd�|�ttjd�|�tjjt��j	u�dS)Nr	i�5w)
rrr�	_getframer)rrN�
test_getframe�__code__�f_coderPrrrr�Is��zSysModuleTest.test_getframecspddl�ddl}��������g��fdd�}����fdd���j|d�}|�����|�t��d��d}t�	�}|D]}|�
|t�|�|d�qA��
�}|�||�|�||�|�|�}|�|t��u�|�|�}|�|�}	t|	�D]\}
\}}}
}|
dkr�nq||�d	�|�|d
�|	|
d\}}}
}|�|
d�|�|dd
g����|��dS)Nrcrur'rr��g456rr�f123^rxz/SysModuleTest.test_current_frames.<locals>.f123cs"������������dSr')�append�	get_ident�set�waitr��	entered_g�leave_g�thread_info�	threadingrrr�asz/SysModuleTest.test_current_frames.<locals>.g456��targetrHr��)didn't find f123() on thread's call stack�g456()r�zleave_g.wait()zentered_g.set())r��	traceback�Event�Thread�startr�rr�r�_current_framesrfr��
assertGreaterr�rE�poprr��
extract_stack�	enumerate�failr��join)rr�r��t�	thread_id�d�tid�main_id�frame�stack�i�filename�lineno�funcname�
sourceliner�r�r�r�r�r�r�test_current_framesRsD


�
z!SysModuleTest.test_current_framescsnddl�ddl}��������g��fdd�}����fdd���j|d�}|�����|�t��d��d}t�	�}|D]}|�
|t�|�|d�qA��
�}|�||�|�||�|�d|�|��|�|�\}}	}
|�|
j�}t|�D]\}\}
}}}|d	kr�nq{|�d
�|�|d�||d\}
}}}|�|d�|�|�d
�����|��dS)Nrcrur'rrr�rrr��rxz3SysModuleTest.test_current_exceptions.<locals>.f123csJ���������	ztd��ty#�jtjd�r!YdSYnwq)NT�oops)�timeout)r�r�r�r)r�r�LONG_TIMEOUTrr�rrr��s���z3SysModuleTest.test_current_exceptions.<locals>.g456r�rH)NNNr�r�r�r�zif leave_g.wait()r�r�r�r�r�r�rr�r�_current_exceptionsrfr�r�r�rEr�r��tb_framer�r�rrYr�r�)rr�r�r�r�r�r�r��exc_type�	exc_value�exc_tbr�r�r�r�r�r�rr�r�test_current_exceptions�sB
�
z%SysModuleTest.test_current_exceptionscCs�|�tjt�|�tjt�tjD]}|�|t�q|�tjt�tjD]}|�|t�q$|�tj	d�|�tj
t�|�tjt�|�tj
t�|�tjt�|�tjt�|�ttj�d�|�tjjd�|�ttj�d�|�tjjddk�|�tjjdk�|�tjjd�|�tjjd	�|�tjjtjj�|�ttjj�t�|�ttjj�t�|�tjjt�|�tjjt�|�tjt�|�ttj�d
�|�tjj dtjj!�t"dd	�D]}|�t#|tjj dtjj �dd�$tjj ��q�|�tjj%t�|�tjj&t�|�tjj't�t(�)d�}tjj*d
v�r\|�tjj+ddh�|�tjj,hd��|dk�rC|�tjj*d�n|dk�rQ|�tjj*d�n|�tjj*ddh�n|�|d�|�tjj-d�|�tjj-d�|�tj.t�|�tj/t�|�tj/d�|�tj0t�|�tj1t�|�tj2t�|�tj3t�|�tj4t�tj5}|�|dd�t�|�t|�d�|�|dt�|�|dt�|�|dt�|�|dd�|�|dt�|�|j6t�|�|j7t�|�|j8t�|�|j9d�|�|j:t�|�|d|j6�|�|d|j7�|�|d|j8�|�|d|j9�|�|d|j:�|�|dk�|�tj;t�|�tj;d�tj0�<d��s\|�tj=t�dSdS)N)�little�big�r�r�r�rrHi�r{�	z'sys.hash_info.modulus {} is a non-prime�Py_HASH_ALGORITHM>�fnv�	siphash24� �@>r�r��r�r��i��r���alpha�beta�	candidate�final)rHrr)�short�legacy�win)>rfr�api_versionr��argv�listrg�	orig_argvrE�	byteorder�builtin_module_names�tuple�	copyright�exec_prefix�base_exec_prefix�
executablerr��
float_info�radix�int_infor�bits_per_digit�sizeof_digit�assertGreaterEqual�default_max_str_digits�str_digits_check_thresholdr�r��
hexversion�	hash_info�
assertLess�modulus�width�range�pow�format�inf�nan�imag�	sysconfig�get_config_var�	algorithm�	hash_bits�	seed_bits�cutoff�maxsize�
maxunicoder��prefix�base_prefix�
platlibdir�version�version_infor�r��micro�releaselevel�serial�float_repr_stylerY�abiflags)r�arg�x�algo�virrr�test_attributes�s�


���


�zSysModuleTest.test_attributescCs6tj}|�t|�d�|�|jd�|�|jd�dS)Nr�)�nt�pthread�solarisN)�	semaphorez
mutex+condN)rr�rr�rE�name�lock)r�inforrr�test_thread_info3szSysModuleTest.test_thread_infocCs|�tjjtjj�dSr')rr�
__stdout__�encoding�
__stderr__rPrrr�
test_435819szSysModuleTest.test_43581cCs~td7a|�ttj�dtt�}|�t�|�|u�|����}|�t�|�|u�Gdd�dt�}|�ttj|d��dS)NrHznever interned beforec@�eZdZdd�ZdS)z$SysModuleTest.test_intern.<locals>.ScS�dS)Nr>rrPrrr�__hash__Mr,z-SysModuleTest.test_intern.<locals>.S.__hash__N)r/r0r1rArrrr�SL�rB�abc)�INTERN_NUMRUNSrrr�internrgr�swapcase)r�s�s2rBrrr�test_intern>szSysModuleTest.test_interncCs�|�tj�d}|D]!}|�ttj|�|�|dkrtnt}|�tttj|��||�q
|�t	tj��|�t
tj�t
|��|�tjjhd��dS)N)�debug�inspect�interactive�optimize�dont_write_bytecode�no_user_site�no_site�ignore_environment�verbose�
bytes_warning�quiet�hash_randomization�isolated�dev_mode�	utf8_mode�warn_default_encoding�int_max_str_digitsrX>rrHr�)
rr�flagsr�boolr�rr��getattr�reprr�rErY)r�attrs�attr�	attr_typerrr�test_sys_flagsRszSysModuleTest.test_sys_flagscCsz|}t|�}|�t��||�Wd�n1swY|�t��|�||�Wd�dS1s6wYdSr')r�rr�__new__)r�sys_attrr.rbrrr�assert_raise_on_new_sys_typecs
�"�z*SysModuleTest.assert_raise_on_new_sys_typecC�|�tj�dSr')rfrr\rPrrr�test_sys_flags_no_instantiationm�z-SysModuleTest.test_sys_flags_no_instantiationcCrgr')rfrr(rPrrr�&test_sys_version_info_no_instantiationpriz4SysModuleTest.test_sys_version_info_no_instantiationcCs tj�td�|�t���dS)Nr�)rJrr�rrfr�rPrrr�+test_sys_getwindowsversion_no_instantiationssz9SysModuleTest.test_sys_getwindowsversion_no_instantiationcCst��dSr')r�_clear_type_cacherPrrr�test_clear_type_cachexsz#SysModuleTest.test_clear_type_cachecCs�ttj�}d|d<tjtjddgtj|d�}|��d�	�}dtj
�d�}|�||�d|d<tjtjddgtj|d�}|��d�	�}|�|d	�d
|d<tjtjddgtjtj|d�}|��\}}|�|d�|�
d
|�|�
d|�d|d<tjtjddgtjtj|d�}|��\}}|�|d�|�
d
|�|�
d|�d|d<tjtjddgtj|d�}|��d�	�}|�|d�dS)N�cp424r_rSzprint(chr(0xa2))�r�envr�¢z
ascii:replace�?rZ)rrGrprTsUnicodeEncodeError:s'\xa2'zascii:z:surrogateescapezprint(chr(0xdcbd))��)�dict�os�environ�
subprocess�Popenrr�PIPE�communicate�strip�linesep�encoderrE)rrp�prr[r:rrr�test_ioencoding|sL
�����zSysModuleTest.test_ioencodingz*requires OS support of non-ASCII encodingsFz$requires FS encoding to match localecCsZttj�}d|d<tjtjddtjgtj	|d�}|�
�d��}|�|t�
tj��dS)Nr
r_rSz	print(%a)ror)rtrurvrwrxrrr�FS_NONASCIIryrzr{r�fsencode)rrpr~rrrr�test_ioencoding_nonascii�s

��z&SysModuleTest.test_ioencoding_nonasciizTest is not venv-compatiblec	Cs�|�tj�tj�tj�tj�tj�tj��}tj	gd�tjtj
|d�}|��d}|���
d�}|��|�|dttj�dd��g�dS)N)�nonexistentrSzEimport sys; print(sys.executable.encode("ascii", "backslashreplace")))rr�cwdr�ASCIIzb''rZ�backslashreplace)rru�path�abspathrr�dirname�realpathrwrxryrzr{�decoder�rEr_r})r�
python_dirr~rrrrr�test_executable�s
�"zSysModuleTest.test_executableNcCs,|�|�t�|�|r|�||�dSdSr')�assertIsNotNone�codecs�lookupr�r�fs_encodingr[rrr�check_fsencoding�s


�zSysModuleTest.check_fsencodingcCs,t��}tjdkrd}nd}|�||�dS)N�darwinzutf-8)r�getfilesystemencodingr�r�r�rrr�test_getfilesystemencoding�s

z(SysModuleTest.test_getfilesystemencodingc
Cs�tj��}||d<d|d<d�d�}tjddd|g}|r!|�d	�|dur*||d
<n|�d
d�tj	|tj
tj|dd�}|��\}}	|S)
N�LC_ALL�0�PYTHONCOERCECLOCALE�
)�
import syszdef dump(name):z    std = getattr(sys, name)z(    print("%s: %s" % (name, std.errors))z
dump("stdin")zdump("stdout")zdump("stderr")�-Xzutf8=0rS�-Ir_T)rrGrp�universal_newlines)
rurv�copyr�rrr�r�rwrxry�STDOUTrz)
r�localerWr<rpr$�argsr~rrGrrr�c_locale_get_error_handler�s$

	

�z(SysModuleTest.c_locale_get_error_handlercCs�|j|dd�}|�|d�|j|dd�}|�|d�|j|dd�}|�|d�|j|d	d�}|�|d�|j|d
d�}|�|d�|j|dd�}|�|d�dS)NT)rWzHstdin: surrogateescape
stdout: surrogateescape
stderr: backslashreplace
z:ignore)r<z6stdin: ignore
stdout: ignore
stderr: backslashreplace
z	iso8859-1z6stdin: strict
stdout: strict
stderr: backslashreplace
z
iso8859-1:�:r
)r�r)rr�rrrr�check_locale_surrogateescape�s0������z*SysModuleTest.check_locale_surrogateescapecC�|�d�dS)N�C�r�rPrrr�test_c_locale_surrogateescaperRz+SysModuleTest.test_c_locale_surrogateescapecCr�)N�POSIXr�rPrrr�!test_posix_locale_surrogateescaperRz/SysModuleTest.test_posix_locale_surrogateescapecCs�ddddd�}|�ttjd��|�ttjd��|�ttjd��|�ttjd	��tjj}|�|dd
�|j|jf�|jd>|jd>B|jd
>B||j	d>B|j
d>B}|�tjj|�|�tjjtjj�
��dS)Nr�r���r�r7r'r�	cache_tagr���r�r�r)rrr�implementationr'rr�r�r)r*r+rr7�lower)r�levelsr'rrrr�test_implementation"s$���

�z!SysModuleTest.test_implementationcCsBddlm}ddg}||�\}}}|�d|�|�ttjd�dS)Nr)rrSz#import sys; sys._debugmallocstats()sfree PyDictObjectsT)�test.support.script_helperrrErrr�_debugmallocstats)rrr��retrr:rrr�test_debugmallocstats8s
z#SysModuleTest.test_debugmallocstats�getallocatedblocksz0sys.getallocatedblocks unavailable on this buildc
Cszddl}Wn
tyt��}Yn wz|��}Wnty.}zd}WYd}~n	d}~ww|dv}t��}|�t	|�t
�|rH|�|d�n|�|d�z
|�
|t���Wn	tyaYnwt��t��}|�||�t��t��}|�|t|d|d��dS)NrT)�pymalloc�pymalloc_debugry)�	_testcapi�ImportErrorr�
with_pymalloc�pymem_getallocatorsnamerrr��assertIsr�r�r�rrr��AttributeError�gc�collect�assertLessEqualrEr)rr�r��
alloc_namer9ri�br�rrr�test_getallocatedblocksCs8����z%SysModuleTest.test_getallocatedblockscCs8|�t��d�d}td|�\}}}|�|��d�dS)NFa�if 1:
            import sys

            class AtExit:
                is_finalizing = sys.is_finalizing
                print = print

                def __del__(self):
                    self.print(self.is_finalizing(), flush=True)

            # Keep a reference in the __main__ module namespace, so the
            # AtExit destructor will be called at Python exit
            ref = AtExit()
        rSsTrue)r�r�
is_finalizingrr�rstrip�rr$r]rrGrrr�test_is_finalizinglsz SysModuleTest.test_is_finalizingcCs@d}td|�\}}}|��}|�d|d�|�d|d�dS)Nz�if 1:
            import sys
            class A:
                def __del__(self, sys=sys):
                    print(sys.flags)
                    print(sys.float_info)
            a = A()
            rSs	sys.flagsrssys.float_inforH)r�
splitlinesrE�rr$r]rr:rrr�test_issue20602�s
zSysModuleTest.test_issue20602cCsDd}td|�\}}}|�|d�|�|��d�|�|��d�dS)Nz�if 1:
            import struct, sys

            class C:
                def __init__(self):
                    self.pack = struct.pack
                def __del__(self):
                    self.pack('I', -42)

            sys.x = C()
            rSrrT)rrr�r�rrr�&test_sys_ignores_cleaning_up_user_data�s
z4SysModuleTest.test_sys_ignores_cleaning_up_user_data�getandroidapilevelzneed sys.getandroidapilevel()cCs$t��}|�|t�|�|d�dS)Nr)rr�rfr�r�)r�levelrrr�test_getandroidapilevel�sz%SysModuleTest.test_getandroidapilevelcs�d���fdd�}gd�}|d|�|d|�|d|dd�|dd��|d|dd�|dd��|d	|d
g�|d
|d
g�|dd>|�|d
d>|d
g�|d|�dS)Nz�if 1:
            import sys
            def f1():
                1 / 0
            def f2():
                f1()
            sys.tracebacklimit = %r
            f2()
        cs<tjtjd�|gtjd�}|��d}��|��|�dS)NrS)rGrH)rwrxrrryrzrr�)�tracebacklimitr[r~r�r$rrr�check�s
�z4SysModuleTest.test_sys_tracebacklimit.<locals>.check)s"Traceback (most recent call last):s&  File "<string>", line 8, in <module>s   File "<string>", line 6, in f2s   File "<string>", line 4, in f1s#ZeroDivisionError: division by zeror�r�r�rHr���r}r)rr�r�rr�r�test_sys_tracebacklimit�s	

z%SysModuleTest.test_sys_tracebacklimitcCs |�ttj�tttj���dSr')rr�r�	meta_pathr�rPrrr�test_no_duplicates_in_meta_path�s z-SysModuleTest.test_no_duplicates_in_meta_path�_enablelegacywindowsfsencodingz*needs sys._enablelegacywindowsfsencoding()cCs:d}tdd�|��\}}}|�dd���}|�|d�dS)N)r�z$sys._enablelegacywindowsfsencoding()zCprint(sys.getfilesystemencoding(), sys.getfilesystemencodeerrors())rSz; rZ�replacezmbcs replace)rr�r�r�rr�rrr�#test__enablelegacywindowsfsencoding�sz1SysModuleTest.test__enablelegacywindowsfsencodingcCs`t�d�}tjdddd|dg}tj|dddd�}tddg�t|�g}|�|j�	��
�||�dS)	Nz]
            import sys
            print(sys.argv)
            print(sys.orig_argv)
        r�r��utf8rSr.T)r��capture_outputr?)�textwrap�dedentrrrw�runr_rrr�r�)rr$r��procr[rrr�test_orig_argv�s

��zSysModuleTest.test_orig_argvcCs*|�tjt�tjD]}|�|t�q
dSr')rfr�stdlib_module_names�	frozensetrg)rr7rrr�test_module_names�s
�zSysModuleTest.test_module_namesr')FN)Br/r0r1rQrdrhrorsr�rJr�cpython_onlyr�r�r��unittest�
skipUnlessrrr��
refcount_testr�r�r�reap_threadsr�r�r2r:r>rJrcrfrhrjrkrmrrr�r�r��getpreferredencodingr��skipIfr%r$r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrNqs�B	
�
	
	
@
B]

+��
�


&

�
'�
!�
rNc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�UnraisableHookTestcCsPddl}ddl}d|��}z|�|||�|jt|�||j||d�Wd}Sd}w)Nr�Exception ignored )r�r��
exc_traceback�err_msg�object)r��types�write_unraisable_exc�SimpleNamespacer��
__traceback__)rr9r�r*r�r��err_msg2rrrr��s

�z'UnraisableHookTest.write_unraisable_exccCsdD]~}|j|d��nd}tj�d��*}tj�tdtj��|�td�||�Wd�n1s1wYWd�n1s@wY|�	�}|dur[|�
d|�d|�d	�|�n
|�
d
|�d	�|�|�
d|�|�
d|�Wd�n1s{wYqdS)
N)Nz
original hook)r�z	an objectrG�unraisablehookr	r�z: r�zException ignored in: �#Traceback (most recent call last):
r3)�subTestrJrrKr-r�__unraisablehook__r�r)rrE)rr�r*rGr:rrr�test_original_unraisablehook�s(
�������z/UnraisableHookTest.test_original_unraisablehookcsVGdd�d�}Gdd�dt��G�fdd�d�}||fD]�}|�|��}|�}tj���"}tj�tdtj��	~Wd�n1sBwYWd�n1sQwY|��}|�	d|�|�	|j
j|�|�	d	|�|�	d
|�||ur�|�	d|�|�	d|�n|�	d|�|�	d
|�|�|�
d��Wd�n1s�wYqdS)Nc@r?)zFUnraisableHookTest.test_original_unraisablehook_err.<locals>.BrokenDelcSstd�}|�)N�
del is brokenr(�rr9rrr�__del__szNUnraisableHookTest.test_original_unraisablehook_err.<locals>.BrokenDel.__del__N�r/r0r1r�rrrr�	BrokenDelrCrc@r?)zOUnraisableHookTest.test_original_unraisablehook_err.<locals>.BrokenStrExceptioncS�td��)Nzstr() is broken��	ExceptionrPrrr�__str__�zWUnraisableHookTest.test_original_unraisablehook_err.<locals>.BrokenStrException.__str__N)r/r0r1rrrrr�BrokenStrExceptionrCrcseZdZ�fdd�ZdS)zOUnraisableHookTest.test_original_unraisablehook_err.<locals>.BrokenExceptionDelcs
��}|�r'rr��rrrr�szWUnraisableHookTest.test_original_unraisablehook_err.<locals>.BrokenExceptionDel.__del__Nrrrrr�BrokenExceptionDelsr	r�zException ignoredztest_sys.pyz	raise excz<exception str() failed>r)r�r�)rr�rJrr4r-rr�rrEr�r1rr7)rrr	�
test_classr*rG�reportrrr� test_original_unraisablehook_errs:
�������z3UnraisableHookTest.test_original_unraisablehook_errc	Cs�Gdd�d�}tj���+}tj�tdtj��|�|j��dd�}Wd�n1s+wYWd�n1s:wY|�	�}d}|�
|�d�|�dS)Nc@seZdZGdd�d�ZdS)zMUnraisableHookTest.test_original_unraisablehook_exception_qualname.<locals>.Ac@seZdZGdd�de�ZdS)zOUnraisableHookTest.test_original_unraisablehook_exception_qualname.<locals>.A.Bc@�eZdZdS)zQUnraisableHookTest.test_original_unraisablehook_exception_qualname.<locals>.A.B.XN�r/r0r1rrrr�X9srN)r/r0r1rrrrrr�B8srN)r/r0r1rrrrr�A7srr�r=r*�/test_original_unraisablehook_exception_qualnamez.<locals>.A.B.X)rJrr4r-rr�r�rrrrE)rrrGr[r�testNamerrrr6s
�����zBUnraisableHookTest.test_original_unraisablehook_exception_qualnamec	Cs�td�}tj�tdtj��+|�t��
t�|�Wd�n1s#wYWd�dSWd�dS1s;wYdS)Nr	r�)	r)rJrr-rr�rrr�r�rrr�'test_original_unraisablehook_wrong_typeEs
���"�z:UnraisableHookTest.test_original_unraisablehook_wrong_typecs�d��fdd�}t�}zEtj�td|��'|�td�d|�}d��D]}|�t	�|�t	||��|f�q"Wd�n1s>wYWd}d�dSWd}d�dSd}d�w)Ncs|�dSr'r�r���	hook_argsrr�	hook_funcOsz@UnraisableHookTest.test_custom_unraisablehook.<locals>.hook_funcr�r	zcustom hookz/exc_type exc_value exc_traceback err_msg object)
r�rJrr-rr�r)�splitrr^)rrr*r[rarrr�test_custom_unraisablehookLs,
����	�	�z-UnraisableHookTest.test_custom_unraisablehookc	Cs�dd�}tj�d��)}tj�td|��|�td�dd�Wd�n1s'wYWd�n1s6wY|��}|�d|�d�|�|�d	|�|�d
|�dS)NcWr)Nzhook_func failedrrrrrrbrzEUnraisableHookTest.test_custom_unraisablehook_fail.<locals>.hook_funcrGr�r	zcustom hook failz)Exception ignored in sys.unraisablehook: r�r�zException: hook_func failed
)	rJrrKr-rr�r)rrE)rrrGr:rrr�test_custom_unraisablehook_failas"
������z2UnraisableHookTest.test_custom_unraisablehook_failN)
r/r0r1r�r�rrrrrrrrrr��s(r�csleZdZdd�ZejjZdd�Zdd�Zdd�Z	�fd	d
�Z
dd�Zd
d�Zdd�Z
dd�Zdd�Z�ZS)�
SizeofTestcCs*t�d�|_tjj|_ddl}|j|_	dS)N�Pr)
�struct�calcsizerrrr
�	longdigitr��SIZEOF_PYGC_HEAD�gc_headsize)rr�rrr�setUpus
zSizeofTest.setUpcCsHtjj}|j}|�t�d�|d�|j�|�t�g�|d�|�dS)NTr
�Pn)rJr�calcvobjsizer"rr�	getsizeofr )r�vsize�gc_header_sizerrr�test_gc_head_size}szSizeofTest.test_gc_head_sizecCs�Gdd�d�}|�ttj|��Gdd�d�}|�ttj|��dg}|�t�|�|�|�Gdd�d�}|�ttj|��|�t�|�|�|�Gdd	�d	t�}|�t�|tj��tj|j	�|�t
��t�|tjd
��Wd�n1s{wY|�t��t�|d��Wd�n1s�wY|�tt
f��t�|tjd
��Wd�dS1s�wYdS)Nc@r?)z)SizeofTest.test_errors.<locals>.BadSizeofcSr&r'r(rPrrr�
__sizeof__�r,z4SizeofTest.test_errors.<locals>.BadSizeof.__sizeof__N�r/r0r1r*rrrr�	BadSizeof�rCr,c@r?)z-SizeofTest.test_errors.<locals>.InvalidSizeofcS�dSr'rrPrrrr*�r,z8SizeofTest.test_errors.<locals>.InvalidSizeof.__sizeof__Nr+rrrr�
InvalidSizeof�rCr.�sentinelc@r?)z+SizeofTest.test_errors.<locals>.FloatSizeofcSr@)Ng@rrPrrrr*�r,z6SizeofTest.test_errors.<locals>.FloatSizeof.__sizeof__Nr+rrrr�FloatSizeof�rCr0c@r?)z.SizeofTest.test_errors.<locals>.OverflowSizeofcSst|�Sr')r�rPrrrr*�rz9SizeofTest.test_errors.<locals>.OverflowSizeof.__sizeof__Nr+rrrr�OverflowSizeof�rCr1rHr�)rr)rr&rr�r�rr"r"�
OverflowError)rr,r.r/r0r1rrr�test_errors�s,
���"�zSizeofTest.test_errorscCsFtjj}|�t�d�|d�|j�|�t�dd�|d�|j�dS)NTr
r�)rJrr%rrr&r )r�sizerrr�test_default�s"zSizeofTest.test_defaultc'	s�	tj}tjj�tjj}�j��d|d��j��t�d��dddg}|D]}t	|�}�||d�|�
��q'�tt	���d���d|d	�d
��d|d	�d�d
d�}�|�jd�d���fdd�}||�j
�d��||j
�d��dd�}||j
�d�|d	���tdd
��d���tj�d��ddl}	�|	jj�d��ddl}
�|
jj�d���tj�d���ij�d���i�d���dd
i�d�|d�dd|d ��d
d!d"d#dd$d%dd&�}�|�d�|d�d'd(|d ���i���d���i���d���i���d���ti��d)���ti����d)���ti����d)���ti����d)��Gd*d+�d+t�}�|j�d���t��d,���t ddddd��d-���t!ddddd��d-���t"ddd
d��d-���t#�d��ddl$}
ddl%}|
�&|j'j(�}�|�d.���t)g��d/���t*d��d���t+d��d0���t,j-|d��j.tt,j-��ddl/}d1}|�0�}t|j1j2�}t|j1j3�}|j1j4|j1j5||d
}�||d2|d3d|d��d4d5�}�|�d6��G��fd7d8�d8�}d9d:�}�|��d;���td<��d=��ddl6}�|�7dd��d���t8g�|d>���t8d
g�|d>�d!�j.��t8d
d!g�|d>�d!�j.��t8gd?��|d>�d#�j.��tg��d=���t*g��d���d|d���d
|d��j��d@|d��j�d!t,j9j:}�t|�|d�d!�j��t|d!d
�|d�d!�j��t|d!�|d�d"�j��t;�dA���d�d���t<�d���t��d��G��fdBd+�d+t�}�tt=d
���dC���t*d��d���t=d
��dD���t=dE��dD��d}gt=d(�t=dF�g}�dG|ddH�}|D]Q}t|�}|dk�rGd
}|d!}|}||k�r[|d
>}||k�sR|dk�rp�t>|�|��t?|�|��q:�t>|�|||d���t?|�|||d���q:�tt>���dI���t@d��dJ���tAt��dJ���dK|d���d?|d�d"�j.�dL}||�}�t|�||dM�}GdNdO�dOt�}�|||dP�dd|d ���|�j�d�d�j.�|�} d
| _B| _C| _D| _E| _F| _G| _H| _I�|||dP�d'd(|d ���|�j�d�d(�j.�gdQ�}dR}!|!dS}"|"d}#|D]L}tJtK|��}$|$dTk�rU�|!�t|�d
}%n.|$dUk�re�|"�t|�d
}%n|$dVk�rw�|"�d!t|�d
}%n�|"�d#t|�d
}%�||%��q=tLdW�}�|�|"�d#�tM|dXdY��|�|"�d#d#�ddlN}&�|&�Ot��dZ���|&�Pt��dZ��dS)[NTr
�5PrT�ui���n2Pi�nPrnrHs
xxxxxxxxxxr�csd��fdd�}|S)Nr	c��Sr'rr�r/rr�inner�r,z<SizeofTest.test_objecttypes.<locals>.get_cell.<locals>.innerr)r<rr;r�get_cell�sz-SizeofTest.test_objecttypes.<locals>.get_cellrrcs��t�|�|�dSr')rrr&)ri�
expected_sizerPrr�check_code_size�r�z4SizeofTest.test_objecttypes.<locals>.check_code_size�6i13Pcs�fdd�}|S)Ncr:r'rrr;rrr<�r,z=SizeofTest.test_objecttypes.<locals>.get_cell2.<locals>.innerr)r/r<rr;r�	get_cell2�sz.SizeofTest.test_objecttypes.<locals>.get_cell2�2d�3PPP�3PP�3P2P�2P�nQ2Pri�2nP2nr�r��n2Pr�r�r���)rHr�r�r�r�rJrKr�r�r��P2nPnc@r
)�&SizeofTest.test_objecttypes.<locals>.CNrrrrrr���r��5Pbz	5Pb 2P2nP�32B2iB�n3Pr���
4Pi2c4P3ic�3icSr-r'rrrrr�func�z)SizeofTest.test_objecttypes.<locals>.func�14Pcs@eZdZedd��Zedd��Z�e�d���e�d��dS)z&SizeofTest.test_objecttypes.<locals>.ccSr-r'rrrrr�foo�z*SizeofTest.test_objecttypes.<locals>.c.foocSr-r'r)�clsrrr�barrYz*SizeofTest.test_objecttypes.<locals>.c.bar�PPN)r/r0r1�staticmethodrX�classmethodr[r�r�r4rrr�s

r�css�dVdS)NrHrrrrr�get_gen&s�
z,SizeofTest.test_objecttypes.<locals>.get_gen�P2PPP4PrD�lPr$)rHr�r�r��PnPPPcs@eZdZdd�Zdd�Zdd�Zeeeed�Z�e�d��d	S)
rMcSs|jSr'��_C__xrPrrr�getxLsz+SizeofTest.test_objecttypes.<locals>.C.getxcSs
||_dSr'rd)r�valuerrr�setxMs
z+SizeofTest.test_objecttypes.<locals>.C.setxcSs|`dSr'rdrPrrr�delxNsz+SizeofTest.test_objecttypes.<locals>.C.delxr
�5PiN)r/r0r1rfrhri�propertyr/rr_rrr�Ks�4l�4Pi�ry�3nP�2nP�P3n�3Pr�P2nPI13Pl4Pn9Pn11PIPP�4P36P3P10P2P5Pc@r
)z2SizeofTest.test_objecttypes.<locals>.newstyleclassNrrrrr�
newstyleclass�rNrt�2nP2n0P)�d1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111udÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿuPĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀu,￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿ux𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀u�􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿�nnbP�nPnr��ii@z<stdin>r#�2Pn2P)QrrrJr�calcobjsizer%�check_sizeofr r��	bytearray�	__alloc__�iter�__closure__r��complexrgr��datetime�	timedelta�days�collections�defaultdict�default_factoryr��__add__�__iter__�keys�values�itemsr��__dict__�
BaseException�UnicodeEncodeError�UnicodeDecodeError�UnicodeTranslateError�Ellipsisr��encodings.iso8859_3�
charmap_build�	iso8859_3�decoding_tabler��reversed�floatrr	rrL�currentframer��co_cellvars�co_freevars�co_stacksize�
co_nlocals�re�finditerrrrr��NotImplementedrr�r��slice�superrir�r�r��erw�g�h�ord�max�chrr"�weakref�ref�proxy)'rrr'�samples�sampler/r=r?rAr�r��longdictr�r��	encodingsrL�CO_MAXBLOCKS�ncells�nfrees�extrasrUr�r`r��PyLong_BASE�
PySet_MINSIZErH�minused�tmp�newsize�fmtrt�o�asciifields�
compactfields�
unicodefields�maxchar�Lr���	__class__)r�rr4r�test_objecttypes�s.*& ���"  $ 	

�

�"0"


zSizeofTest.test_objecttypescCsHt�|�t�|�}t�|�rt�|�s||j7}|�t�|�|�dSr')rr&rrr��
is_trackedr"r)rr*�base�extrar[rrr�check_slots�s
zSizeofTest.check_slotsc	Cs�|j}Gdd�dt�}||�t�d�Gdd�dt�}||gd�dgid�Gdd	�d	t�}||�gd�Gd
d�dt�}||�t�d�Gdd
�d
t�}||�t�d�ddlm}Gdd�d|�}||gd�|gd�d�dS)Nc@�eZdZdZdS)z!SizeofTest.test_slots.<locals>.BA�rir�r�N�r/r0r1�	__slots__rrrr�BA��r�rqc@r�)z SizeofTest.test_slots.<locals>.Dr�Nr�rrrr�D�r�r�r;r/c@r�)z SizeofTest.test_slots.<locals>.Lr�Nr�rrrrr��r�r�c@r�)z SizeofTest.test_slots.<locals>.Sr�Nr�rrrrrB�r�rBc@r�)z!SizeofTest.test_slots.<locals>.FSr�Nr�rrrr�FS�r�r�r)�OrderedDictc@r�)z!SizeofTest.test_slots.<locals>.ODr�Nr�rrrr�OD�r�r�)r�r}rtrr�r�r�r�)	rr�r�r�r�rBr�r�r�rrr�
test_slots�szSizeofTest.test_slotscCs�tjj}tjj}|j}ddl}||��|d��zt�ty4t�	�d}|dur2|||d��Ynw|tj
|d�|jttj
��dS)Nrrr��2P2ir
)
rJrr{r%r|�_ast�ASTrrr6r\rr�)rr4r'r�r��tbrrr�test_pythontypes�s��$zSizeofTest.test_pythontypescCs�t��}|�|j�|�|j�dd�}tj|d�t��}|�|j|�|�|d|�|�|jd�|�|dd�dd�}tj|d�t��}|�|j|�|�|d|�|�|j|�|�|d|�tj|�t��}|�|j�|�|j�dS)NcWr-r'r�rirrr�<lambda>�rVz0SizeofTest.test_asyncgen_hooks.<locals>.<lambda>)�	firstiterrrHcWr-r'rr�rrrr��rV)�	finalizer)r�get_asyncgen_hooksrar�r��set_asyncgen_hooksr�)r�oldr��hooksr��currrr�test_asyncgen_hooks�s*
zSizeofTest.test_asyncgen_hookscCs6t�d�}td|�\}}}|�|d�|�|d�dS)Nz�
            import sys
            class MyStderr:
                def write(self, s):
                    sys.stderr = None
            sys.stderr = MyStderr()
            1/0
        rSrT)r�r�rrr�rrr�/test_changing_sys_stderr_and_removing_references
z:SizeofTest.test_changing_sys_stderr_and_removing_reference)r/r0r1r#rJrr|r)r3r5r�r�r�r�r�r��
__classcell__rrr�rrrs	
r�__main__)rr�r�r�r�rurrwrr�test.supportrJrrr�rrrr�r�r@rE�TestCaserr2rNr�r�rr/�mainrrrr�<module>sP/(!�

Youez - 2016 - github.com/yon3zu
LinuXploit