403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.216.238
Web Server : Apache
System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64
User : c9415830 ( 11735)
PHP Version : 8.4.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python36/lib64/python3.6/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python36/lib64/python3.6/test/__pycache__/test_exceptions.cpython-36.pyc
3

�w2_u��@s�ddlZddlZddlZddlZddlZddlZddlZddlmZm	Z	m
Z
mZmZm
Z
mZmZmZmZmZmZGdd�de�ZGdd�de�ZGdd�de�ZGd	d
�d
ej�ZGdd�dej�Zed
kr�ej�dS)�N)�TESTFN�captured_stderr�check_impl_detail�check_warnings�cpython_only�
gc_collect�run_unittest�
no_tracing�unlink�
import_module�
script_helper�SuppressCrashReportc@seZdZdd�ZdS)�NaiveExceptioncCs
||_dS)N)�x)�selfr�r�9/opt/alt/python36/lib64/python3.6/test/test_exceptions.py�__init__szNaiveException.__init__N)�__name__�
__module__�__qualname__rrrrrrsrc@seZdZdZdd�ZdS)�SlottedNaiveExceptionrcCs
||_dS)N)r)rrrrrrszSlottedNaiveException.__init__N)r)rrr�	__slots__rrrrrrsrc@seZdZdd�ZdS)�BrokenStrExceptioncCstd��dS)Nzstr() is broken)�	Exception)rrrr�__str__szBrokenStrException.__str__N)rrrrrrrrrsrc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zedd��Z	d
d�Z
eje
jdkd�dd��Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zed#d$��Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Z d3d4�Z!d5d6�Z"d7d8�Z#d9d:�Z$d;d<�Z%d=d>�Z&d?d@�Z'dAdB�Z(dCdD�Z)dEdF�Z*dGdH�Z+dIdJ�Z,edKdL��Z-edMdN��Z.edOdP��Z/edQdR��Z0edSdT��Z1edUdV��Z2edWdX��Z3edYdZ��Z4d[d\�Z5d]d^�Z6d_d`�Z7edadb��Z8dcS)d�ExceptionTestscCs�y|d��Wn*|k
r6}zt|�}WYdd}~XnXy|d��Wn*|k
rn}zt|�}WYdd}~XnX|j||�|j|j|�dS)NZspam)�str�assertEqualr)r�excZexcname�errZbuf1Zbuf2rrr�raise_catch szExceptionTests.raise_catchcGCs�|jtd�|jtttd�|jtd�ttd�}|j�ttd�}tj	}z0yddl
}|jd�Wntk
rvYnXWd|t_	|j�tt�X|jt
d�|jt
td	d�|jtd
�|jttd�|jtd�g}|jt|jd
�|jtd�i}|jt|jd�|jtd�|jtd�|jtd�yt}Wntk
�rLYnX|jtd�d}xtd�D]}||7}�qhW|jtd�|jtd�|jtd�ytd�Wntk
�r�YnX|jtd�|jtd�ytddd�Wntk
�rYnX|j d�|jt!d �|jt"d!�|jt"tj#d�|jt$d"�ygfWnt$k
�rbYnX|jt%d#�|jt%t&d)�|jt'd&�ydd}Wnt'k
�r�YnX|jt(d'�ydd}Wn$t(k
�r�}zWYdd}~XnX|jt)d(�dS)*N�AttributeErrorZundefined_attribute�EOFError�w�rr��OSErrorzthis file does not exist�ImportErrorZundefined_module�
IndexError�
�KeyError�key�KeyboardInterrupt�MemoryError�	NameError�
OverflowError���RuntimeError�RecursionError�SyntaxErrorz/
�IndentationError�TabErrorz"try:
	1/0
    	1/0
finally:
 pass
z<string>�execzTabError not raised�SystemError�
SystemExit�	TypeError�
ValueError���ZeroDivisionErrorr�StopAsyncIterationi)*r!r"�assertRaises�getattr�sysr#�openr�close�stdin�marshal�loadsr
r'r(�
__import__r)�__getitem__r+r-r.r/Zundefined_variabler0�ranger3r4r5r8r6r7�compile�failr9r:�exitr;r<�chrr?rr@)r�fpZ	savestdinrGrZdummy�errr�testRaising,s�




zExceptionTests.testRaisingcsB�fdd�}d}tjjd�s&||d�d}||d�|dd�dS)	Ncs`yt|dd�Wn@tk
rP}z$|j|kr@�jd||jf�WYdd}~XnX�jd�dS)Nz
<fragment>r8zexpected %s, got %sz"failed to get expected SyntaxError)rLr5�msgrM)�srcrSrQ)rrr�ckmsg�s
&z4ExceptionTests.testSyntaxErrorMessage.<locals>.ckmsgz\while 1:
            try:
                pass
            finally:
                continue�javaz0'continue' not supported inside 'finally' clausezHif 1:
        try:
            continue
        except:
            passz'continue' not properly in loopz	continue
)rC�platform�
startswith)rrU�sr)rr�testSyntaxErrorMessage�s


z%ExceptionTests.testSyntaxErrorMessagecs^tf�fdd�	}d}||d�d}||d�d}||d�d	}||d
t�d}||dt�dS)
Ncs`yt|dd�Wn@|k
rP}z$|j|kr@�jd||jf�WYdd}~XnX�jd�dS)Nz
<fragment>r8zexpected %s, got %sz"failed to get expected SyntaxError)rLrSrM)rTrS�	exceptionrQ)rrrrU�s
&z:ExceptionTests.testSyntaxErrorMissingParens.<locals>.ckmsgzprint "old style"zHMissing parentheses in call to 'print'. Did you mean print("old style")?zprint "old style",zQMissing parentheses in call to 'print'. Did you mean print("old style", end=" ")?zexec "old style"z%Missing parentheses in call to 'exec'zif True:
print "No indent"zexpected an indented blockz6if True:
        print()
	exec "mixed tabs and spaces"z2inconsistent use of tabs and spaces in indentation)r5r6r7)rrUrYr)rr�testSyntaxErrorMissingParens�s	


z+ExceptionTests.testSyntaxErrorMissingParenscsL�fdd�}|ddd�|ddd�|d	d
d�|ddd�|d
dd�dS)NcsF�jt��}t|dd�WdQRX�j|jj|��j|jj|�dS)Nz
<fragment>r8)rAr5rLrr[�lineno�offset)rTr]r^�cm)rrr�check�sz3ExceptionTests.testSyntaxErrorOffset.<locals>.checkzdef fact(x):
	return x!
�r*z1 +
r1�z def spam():
  print(1)
 print(2)�zPython = "Python" +�uPython = "Ṕýţĥòñ" +r)rr`r)rr�testSyntaxErrorOffset�sz$ExceptionTests.testSyntaxErrorOffsetcsjGdd�dt��Gdd�d����fdd�}��fdd�}��fd	d
�}tjjd�sf|�|�|�dS)Nc@seZdZdd�ZdS)z9ExceptionTests.testSettingException.<locals>.BadExceptioncSstd��dS)Nzcan't instantiate BadException)r3)Zself_rrrr�szBExceptionTests.testSettingException.<locals>.BadException.__init__N)rrrrrrrr�BadException�srfc@seZdZdS)z=ExceptionTests.testSettingException.<locals>.InvalidExceptionN)rrrrrrr�InvalidException�srgcs�ddl}y|j�d�WnXtk
rp}z<tj�\}}}|jj}�j|jd��j	|j
jd��WYdd}~XnX�jd�dS)Nrr1�
test_capi1ztest_exceptions.pyzExpected exception)
�	_testcapi�raise_exceptionr;rC�exc_info�tb_frame�f_coder�co_name�
assertTrue�co_filename�endswithrM)rir r�tb�co)rfrrrrh�s$z7ExceptionTests.testSettingException.<locals>.test_capi1cs�ddl}y|j�d�Wnptk
r�}zTtj�\}}}|jj}�j|jd��j	|j
jd��|jjj}�j|jd�WYdd}~XnX�j
d�dS)Nrrztest_exceptions.py�
test_capi2zExpected exception)rirjr3rCrkrlrmrrnrorprq�f_backrM)rir rrrrsZco2)rfrrrrt�s
 z7ExceptionTests.testSettingException.<locals>.test_capi2csddl}�jt|j�d�dS)Nrr1)rirAr9rj)ri)rgrrr�
test_capi3�s
z7ExceptionTests.testSettingException.<locals>.test_capi3rV)rrCrWrX)rrhrtrvr)rfrgrr�testSettingException�sz#ExceptionTests.testSettingExceptionc
Cs�ytWntk
rY�n�X|jtt�|jttd��d�|jttdd��d�tddd�}|j|jd�|j|jd�|jt|�d�td	ddd
�}|j|jd�|j|jd
�|j|jd�|j|j	d�|j|j
d�|jt|�d�td	ddd�}|j|jd
�|j|jd�|j|jd�|j|j	d�|j|j
d�|jt|�d�tdd�}|j|jd�|j|jd�|j|jd�|j|j	d�|j|j
d�dS)Ni�Z1001�messagez[Errno 1001] message�	�foo�barz[Errno 9] foo: 'bar'rrcraz[WinError 3] foo: 'bar'�z[WinError 1001] foo)�WindowsErrorr/�assertIsr'rr�errno�winerror�strerror�filename�	filename2)rr$rrr�test_WindowsError�s@
z ExceptionTests.test_WindowsErrorZwin32ztest specific to Windowsc	Cs8td�}d}|jtd|��|jj|�WdQRXdS)z:Should fill in unknown error code in Windows error message�ctypeslcs�@zWindows Error 0x%xN)r�assertRaisesRegexr'Z	pythonapiZPyErr_SetFromWindowsErr)rr��coderrr�test_windows_messagesz#ExceptionTests.test_windows_messagecCs"tfdfiftd)dd*iftd+dd,iftd-dd.iftd/d0dd�ftd1d2ddddd�ftd3d4ddddd�ftd5d6ddddd�ftd7d8ddd	�ftd9d:dd
dd
�ftd;d<ddddd�ftfddddddd�ftd=d>ddddddd�ftd@dddBddddd�ftdCddDdddddd�ftfdfiftdEdFddddd�ftdtd�dddfdtd�dddfddddd�ftdGdHddddd�ftdIdJddddd �ft	dKdLdd!�ft
dMdNdd!�fg}y"|jtdOdPdddddd"�f�Wnt
k
�r�YnX�x:|D�]0\}}}y||�}Wn$td#||ftjd$��Yn�Xt|�jjd%��sJ|jt|�jd&�t|�}xB|D]:}t||�}|jt|�t||�d'|||||f��qXWx�tgD]v}	xnt|	jd�D]\}
|	j||
�}|	j|�}x>|D]6}tt||��}t||�}
|j||
d(||f��q�W�q�W�q�W�q�WdS)QN�argsr1rz)r�r�)r�r�r�rr�r{�baz�quux)r�r�r��errnoStr�strErrorStr�filenameStr)r�r�rr�)r�rr�r�r�)rS�textr�r]r^�print_file_and_line�msgStr)r�r�r�rSr�r]r^�	linenoStr�	offsetStr�textStr)r^r�r�r�rSr�r]�print_file_and_lineStr)r�r�r�rSr�r]r^�ascii�ar�ordinal not in range)r��encoding�object�start�reason���あ�ouch)r�r�r�r��end)r�r)r�r�r�rr�r�z
exc=%r, args=%r)�filer�builtinsz%r.%s == %r, expected %rzpickled "%r", attribute "%s)r1)r1)rz)rz)rzr1)rzr1)rz)rz)rz)rz)rzr{)rzr{)rzr{r�)rzr{)rzr{r�Nr�)rzr{)r�r�r�)r�r�)r1r�r�)r1r�)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�r�rr1r�)r�r�rr1r�)r�r�rr1r�)r�r�rr1r�)r�rr1r�)r�rr1r�)rz)rz)rz)rz)r1r�r�)r1r�)�
BaseExceptionr:r'r5�UnicodeError�UnicodeEncodeError�UnicodeDecodeError�	bytearray�UnicodeTranslateErrorrr�appendr}r/�printrC�stderr�typerrqrrrrB�repr�picklerK�HIGHEST_PROTOCOL�dumpsrH)rZ
exceptionListrr�ZexpectedrQrYZcheckArgName�value�pZprotocol�newZgotZwantrrr�testAttributes)s�
















zExceptionTests.testAttributesc
Cs�ytd��Wntj�d}YnXt�j|�}|j|t�|j|j|�td�j|�}|j|t�|j|j|�Gdd�dt�}|�j|�}|j||�|j|j|�dS)Nrbra�c@seZdZdS)z5ExceptionTests.testWithTraceback.<locals>.MyExceptionN)rrrrrrr�MyException�sr�)	r)rCrkr��with_traceback�assertIsInstancer�
__traceback__r)rrrrQr�rrr�testWithTraceback�sz ExceptionTests.testWithTracebackcCsNydt�_Wn2tk
r>}z|jdt|��WYdd}~XnX|jd�dS)Nr�z!__traceback__ must be a tracebackzNo exception raised)rr�r;�assertInrrM)rrQrrr�testInvalidTraceback�s
"z#ExceptionTests.testInvalidTracebackcCsP|jttt�dd�|jttt�d�|jttt�dd�|jttt�d�dS)N�	__cause__r1�__context__)rAr;�setattrr�delattr)rrrr�testInvalidAttrs�szExceptionTests.testInvalidAttrsc	CsJytd��Wntj�d}YnXt�}||_d|_|j|jd�dS)Nrbra)r)rCrkrr�r)rrrrQrrr�testNoneClearsTracebackAttr�sz*ExceptionTests.testNoneClearsTracebackAttrcCsnt�}|j|j�|j|j�t�}|j|j�|j|j�Gdd�dt�}|�}|j|j�|j|j�dS)Nc@seZdZdS)z5ExceptionTests.testChainingAttrs.<locals>.MyExceptionN)rrrrrrrr��sr�)r�assertIsNoner�r�r;r')rrQr�rrr�testChainingAttrs�sz ExceptionTests.testChainingAttrscCs�y
t��Wn&tk
r0}z
|}WYdd}~XnX|j|j�|j|j�|j|j�t�|_d|_|j|jt�|j|j�|j|j�d|_|j|j�dS)NF)	rr�r�r�ZassertFalse�__suppress_context__r/r�ro)rrrQrrr�testChainingDescriptors�s
z&ExceptionTests.testChainingDescriptorscCs<|jttdd�Gdd�dt�}|dd�}|j|jd�dS)Nr1)r�c@seZdZdd�ZdS)z8ExceptionTests.testKeywordArgs.<locals>.DerivedExceptioncSstj|�||_dS)N)r�r�	fancy_arg)rr�rrrr�s
zAExceptionTests.testKeywordArgs.<locals>.DerivedException.__init__N)rrrrrrrr�DerivedException�sr��*)r�)rAr;r�rr�)rr�rrrr�testKeywordArgs�s
zExceptionTests.testKeywordArgscs4�fdd��|jt���fdd��|jt��dS)Ncs��S)Nrr)�frrr�sz/ExceptionTests.testInfiniteRecursion.<locals>.fcs y��Stk
rdSXdS)Nr1���)r<r)�grrr�
sz/ExceptionTests.testInfiniteRecursion.<locals>.g)rAr4)rr)r�r�r�testInfiniteRecursionsz$ExceptionTests.testInfiniteRecursioncCs8|jtt��|jttd���|jttdd���dS)Nr��b)rorr)rrrr�test_strszExceptionTests.test_strcCsLy
t��Wn.tk
r8}z|j|�~WYdd}~XnX|jdt��dS)NrQ)rroZassertNotIn�locals)rrQrrr�testExceptionCleanupNamess

z(ExceptionTests.testExceptionCleanupNamescIs�Gdd�dt��Gdd�d�}��fdd�}|��tj��}y
|�Wn"�k
rh}zWYdd}~XnXd�|��|j�dkd��|��tj��}y
|�Wn�k
r�YnXd�|��|j�dkd��|��tj��}y
|�WnYnXd�|��|j�dkd��|��tj��}x(d
D] }y
|�WnPYnX�q2Wd�|��|j�dkd��|��tj��}y y
|�Wnt�YnXWnZtk
�r�}z<d|_d�|��td	d
��r�t�|j�dkd��WYdd}~XnX|��tj��}y
|�Wn>�k
�rXyz�Wd�XWn�k
�rRYnXYnXd�td	d
��rpt�|��|j�dkd��Gdd�d�}|��tj��}|��|�WdQRXd�td	d
��r�t�|��|j�dkd��dS)Nc@seZdZdd�ZdS)z=ExceptionTests.testExceptionCleanupState.<locals>.MyExceptioncSs
||_dS)N)�obj)rr�rrrr&szFExceptionTests.testExceptionCleanupState.<locals>.MyException.__init__N)rrrrrrrrr�%sr�c@seZdZdS)z7ExceptionTests.testExceptionCleanupState.<locals>.MyObjN)rrrrrrr�MyObj(sr�cs�}����dS)Nr)Z	local_ref)r�r�rr�inner_raising_func+szDExceptionTests.testExceptionCleanupState.<locals>.inner_raising_funcz%srF)Zcpythonc@seZdZdd�Zdd�ZdS)z9ExceptionTests.testExceptionCleanupState.<locals>.ContextcSs|S)Nr)rrrr�	__enter__�szCExceptionTests.testExceptionCleanupState.<locals>.Context.__enter__cSsdS)NTr)r�exc_type�	exc_valueZexc_tbrrr�__exit__�szBExceptionTests.testExceptionCleanupState.<locals>.Context.__exit__N)rrrr�r�rrrr�Context�sr�)r)r�weakref�refror+r�rr)rr�r��wrrQ�ir�r)r�r�r�testExceptionCleanupState!s�










&


z(ExceptionTests.testExceptionCleanupStatecsB�fdd�}ytWn(tk
r<�z|�WYdd��XnXdS)Ncs�dS)Nrr)rQrr�print_error�szIExceptionTests.test_exception_target_in_nested_scope.<locals>.print_error)Z	somethingr)rr�r)rQr�%test_exception_target_in_nested_scope�s
z4ExceptionTests.test_exception_target_in_nested_scopecCsdd�}|�}|jt|�t�|jtj�dd�|jt|�t�|jtj�dd�|jt|�d�ytd��Wn�tk
r�|�}|jt|�t�|jtj�dt�|jt|�t�|jtj�dt�|jt|�t�~|jtj�dt�YnXdS)NcssPytd��Wn0tk
r<tj�dVtj�dVYnXtj�dVdS)NZcaughtr)r+rCrkrrrr�yield_raise�sz:ExceptionTests.test_generator_leaking.<locals>.yield_raiserrz)r�nextr+rCrkr;)rr�r�rrr�test_generator_leaking�s$z%ExceptionTests.test_generator_leakingcCsjdd�}yt�Wn"tk
r2|�}t|�YnXyt|�Wntk
rTYnX|jtj�d�dS)Ncss
dVdS)Nrrrrrr��sz1ExceptionTests.test_generator_leaking2.<locals>.g)NNN)r3r��
StopIterationrrCrk)rr��itrrr�test_generator_leaking2�sz&ExceptionTests.test_generator_leaking2cCs�dd�}|�}t|�yddWn`tk
r�}zD|jtj�d|�|j|�}|jtj�d|�|j||�WYdd}~XnX|jtj�d�dS)Ncss2y
dVWn"tk
r,tj�dVYnXdS)Nr1)r?rCrkrrrrr��s
z1ExceptionTests.test_generator_leaking3.<locals>.gr1r)NNN)r�r?r~rCrk�throwr)rr�r�rQZgen_excrrr�test_generator_leaking3�s
z&ExceptionTests.test_generator_leaking3cCs�dd�}|�}yt�Wntk
r2t|�}YnX|j|t�yt|�Wn6tk
r�}z|jtj�d|�WYdd}~XnX|jtj�d�dS)Ncss6yddWn$tk
r0tj�dV�YnXdS)Nr1r)r?rCrkrrrrr��s
z1ExceptionTests.test_generator_leaking4.<locals>.gr1)NNN)r;r�r~r?rCrkr)rr�r��tprQrrr�test_generator_leaking4�s&z&ExceptionTests.test_generator_leaking4csJ�fdd�}|�}yt�Wntk
r6t|�YnX�jtt|�dS)Nc3s.�jtj�dt�dV�jtj�d�dS)Nr1)NNN)r�rCrkr3rr)rrrr��sz>ExceptionTests.test_generator_doesnt_retain_old_exc.<locals>.g)r3r�rAr�)rr�r�r)rr�$test_generator_doesnt_retain_old_exc�sz3ExceptionTests.test_generator_doesnt_retain_old_exccs4dd���fdd�}|�t�|jtj�d�dS)Ncss
dVdS)Nr1rrrrr�
simple_gen	szIExceptionTests.test_generator_finalizing_and_exc_info.<locals>.simple_gencs,��}yt�Wntk
r&t|�SXdS)N)r3r�)�gen)r�rr�run_gens
zFExceptionTests.test_generator_finalizing_and_exc_info.<locals>.run_gen)NNN)rrrCrk)rr�r)r�r�&test_generator_finalizing_and_exc_infos
z5ExceptionTests.test_generator_finalizing_and_exc_infocspGdd�dt��Gdd�d�}��fdd�}|��tj��}|�}t|�||�d}�|��|j�d�dS)Nc@seZdZdd�ZdS)zFExceptionTests._check_generator_cleanup_exc_state.<locals>.MyExceptioncSs
||_dS)N)r�)rr�rrrrszOExceptionTests._check_generator_cleanup_exc_state.<locals>.MyException.__init__N)rrrrrrrrr�sr�c@seZdZdS)z@ExceptionTests._check_generator_cleanup_exc_state.<locals>.MyObjN)rrrrrrrr�sr�c3s,y����Wn�k
r&dVYnXdS)Nrr)r�r�rr�raising_genszFExceptionTests._check_generator_cleanup_exc_state.<locals>.raising_gen)rr�r�r�r~)rZtestfuncr�r�r�r�r)r�r�r�"_check_generator_cleanup_exc_states
z1ExceptionTests._check_generator_cleanup_exc_statecCsdd�}|j|�dS)NcSs*y|jt��Wntk
r$YnXdS)N)r�r3)r�rrr�do_throw.szGExceptionTests.test_generator_throw_cleanup_exc_state.<locals>.do_throw)r�)rr�rrr�&test_generator_throw_cleanup_exc_state-sz5ExceptionTests.test_generator_throw_cleanup_exc_statecCsdd�}|j|�dS)NcSs|j�dS)N)rE)r�rrr�do_close6szGExceptionTests.test_generator_close_cleanup_exc_state.<locals>.do_close)r�)rr�rrr�&test_generator_close_cleanup_exc_state5sz5ExceptionTests.test_generator_close_cleanup_exc_statecCsdd�}|j|�dS)NcSsd}dS)Nr)r�rrr�do_del;szCExceptionTests.test_generator_del_cleanup_exc_state.<locals>.do_del)r�)rr�rrr�$test_generator_del_cleanup_exc_state:sz3ExceptionTests.test_generator_del_cleanup_exc_statecs�fdd�}�j|�dS)Ncs0yt|�Wntk
r YnX�jd�dS)Nz should have raised StopIteration)r�r�rM)r�)rrr�do_next@s
zEExceptionTests.test_generator_next_cleanup_exc_state.<locals>.do_next)r�)rr�r)rr�%test_generator_next_cleanup_exc_state?sz4ExceptionTests.test_generator_next_cleanup_exc_statecs�fdd�}�j|�dS)Ncs2y|jd�Wntk
r"YnX�jd�dS)Nz should have raised StopIteration)�sendr�rM)r�)rrr�do_sendJs
zEExceptionTests.test_generator_send_cleanup_exc_state.<locals>.do_send)r�)rr�r)rr�%test_generator_send_cleanup_exc_stateIsz4ExceptionTests.test_generator_send_cleanup_exc_statecsBG�fdd�d�}f�yt|���WnYnX|j�d�dS)NcseZdZ�fdd�ZdS)z*ExceptionTests.test_3114.<locals>.MyObjectcstj��dS)N)rCrk)r)rQrr�__del__Wsz2ExceptionTests.test_3114.<locals>.MyObject.__del__N)rrrrr)rQrr�MyObjectVsr)NNN)rr)rrr)rQr�	test_3114SszExceptionTests.test_3114cCsftddddd�}|jt|�d�d|_|jt|�d�d|_d	|_|jt|�d
�d|_|jt|�d�d
|_|jt|�d�tddddd�}|jt|�d�d|_|jt|�d�d|_d	|_|jt|�d�d|_|jt|�d�d
|_|jt|�d�tdddd�}|jt|�d�d|_|jt|�d�d|_d	|_|jt|�d�d
|_|jt|�d�dS)Nr�Zxxxxxr1r�rzz8'baz' codec can't encode characters in position 1-4: fooraz<'baz' codec can't encode character '\x78' in position 1: foolESh
MQ)EzJ'baz' codec can't encode characters in position 1-4: 965230951443685724997i�zK'4000' codec can't encode characters in position 1-4: 965230951443685724997i�zN'4000' codec can't encode characters in position 1000-4: 965230951443685724997sxxxxxz3'baz' codec can't decode bytes in position 1-4: fooz5'baz' codec can't decode byte 0x78 in position 1: foozE'baz' codec can't decode bytes in position 1-4: 965230951443685724997zF'4000' codec can't decode bytes in position 1-4: 965230951443685724997zI'4000' codec can't decode bytes in position 1000-4: 965230951443685724997Zxxxxz/can't translate characters in position 1-4: fooz3can't translate character '\x78' in position 1: foozAcan't translate characters in position 1-4: 965230951443685724997zDcan't translate characters in position 1000-4: 965230951443685724997)	r�rrr�r�r�r�r�r�)r�urrr�test_unicode_change_attributesas>z-ExceptionTests.test_unicode_change_attributescCs2tttf}x"|D]}|jt|j|��d�qWdS)N�)r�r�r�rr�__new__)rZklasses�klassrrr�test_unicode_errors_no_object�s

z,ExceptionTests.test_unicode_errors_no_objectcs�Gdd�dt�}Gdd�dt|d�}t��n}y
t��WnR|k
rb}z|jd�WYdd}~Xn2tk
rtYn |jd�YnX|jd�WdQRX�fdd	����\}}}|jt|t�t|��|jd
t	|��dS)Nc@seZdZdd�ZdS)z/ExceptionTests.test_badisinstance.<locals>.MetacSs
t��dS)N)r<)�cls�subclassrrr�__subclasscheck__�szAExceptionTests.test_badisinstance.<locals>.Meta.__subclasscheck__N)rrrrrrrr�Meta�src@seZdZdS)z6ExceptionTests.test_badisinstance.<locals>.MyExceptionN)rrrrrrrr��sr�)�	metaclassz%exception should not be a MyExceptionzShould have raised KeyErrorcs$y��Stk
rtj�SXdS)N)r4rCrkr)r�rrr��sz,ExceptionTests.test_badisinstance.<locals>.gz maximum recursion depth exceeded)
r�rrr+rMro�
isinstancer4r�r)rrr�r�rQ�vrrr)r�r�test_badisinstance�s 
z!ExceptionTests.test_badisinstancecCsPdt}tjdd|�\}}}|j|d�|jd|�|jd|�|jd|�dS)Na�if 1:
            import sys
            from _testcapi import get_recursion_depth

            class MyException(Exception): pass

            def setrecursionlimit(depth):
                while 1:
                    try:
                        sys.setrecursionlimit(depth)
                        return depth
                    except RecursionError:
                        # sys.setrecursionlimit() raises a RecursionError if
                        # the new recursion limit is too low (issue #25274).
                        depth += 1

            def recurse(cnt):
                cnt -= 1
                if cnt:
                    recurse(cnt)
                else:
                    generator.throw(MyException)

            def gen():
                f = open(%a, mode='rb', buffering=0)
                yield

            generator = gen()
            next(generator)
            recursionlimit = sys.getrecursionlimit()
            depth = get_recursion_depth()
            try:
                # Upon the last recursive invocation of recurse(),
                # tstate->recursion_depth is equal to (recursion_limit - 1)
                # and is equal to recursion_limit when _gen_throw() calls
                # PyErr_NormalizeException().
                recurse(setrecursionlimit(depth + 2) - depth - 1)
            finally:
                sys.setrecursionlimit(recursionlimit)
                print('Done.')
        z-Wdz-cr1sRecursionErrorsResourceWarningsDone.)�__file__r�assert_python_failurerr�)rr��rc�outr rrr�$test_recursion_normalizing_exception�s3z3ExceptionTests.test_recursion_normalizing_exceptioncCs>d}tjd|�\}}}|j|d�|jd|�|jd|�dS)Nz�if 1:
            import _testcapi
            try:
                raise _testcapi.RecursingInfinitelyError
            finally:
                print('Done.')
        z-cr1sORecursionError: maximum recursion depth exceeded while normalizing an exceptionsDone.)rrrr�)rr�rrr rrr�-test_recursion_normalizing_infinite_exception�sz<ExceptionTests.test_recursion_normalizing_infinite_exceptionc
Cs8d}t��$tjd|�\}}}|jd|�WdQRXdS)Na+if 1:
            import _testcapi
            class C(): pass
            def recurse(cnt):
                cnt -= 1
                if cnt:
                    recurse(cnt)
                else:
                    _testcapi.set_nomemory(0)
                    C()
            recurse(16)
        z-csRFatal Python error: Cannot recover from MemoryErrors while normalizing exceptions.)r
rrr�)rr�rrr rrr�)test_recursion_normalizing_with_no_memory�s
z8ExceptionTests.test_recursion_normalizing_with_no_memorycs@ddl�ddlm����fdd�}|�}|�}�j||�dS)Nr)�raise_memoryerrorcsHy
��Wn(tk
r2}z|j}WYdd}~XnX�jd��j|�S)Nz Should have raises a MemoryError)r.r�rM�	format_tb)rQrr)rr�	tracebackrr�
raiseMemErrors

z6ExceptionTests.test_MemoryError.<locals>.raiseMemError)rrirr)rrZtb1Ztb2r)rrrr�test_MemoryErrors	zExceptionTests.test_MemoryErrorc
Cs"ddl}d}d}|jt|jd�|jd�}|jt|�t�|jt|t��|j	|j
�|jd|�}|j|j
|�|jd|d�}|jt||��Gd	d
�d
t�}|jd|||f�}|jt||��|jt||��|j|j
|�|jdd
|ddi�}	|jt|	|��|j|	j
d�|j|	j
d
�dS)NrzThis is a test docstring.zThis is another test docstring.�error1z_testcapi.error1z_testcapi.error2z_testcapi.error3)�basec@seZdZdS)z1ExceptionTests.test_exception_with_doc.<locals>.CN)rrrrrrr�C;srz_testcapi.error4z_testcapi.error5rr�r1)rirAr9Zmake_exception_with_docr~r�ro�
issubclassrr��__doc__rr�r�)
rriZdoc2Zdoc4rZerror2Zerror3rZerror4Zerror5rrr�test_exception_with_doc"s2


z&ExceptionTests.test_exception_with_doccs�ddlm�Gdd�d��d����fdd�}y
|�Wn0tk
rh}z|j��d�WYdd}~XnX|jd�|j��d�dS)Nr)rc@seZdZdS)z3ExceptionTests.test_memory_error_cleanup.<locals>.CN)rrrrrrrrOsrcs��}tj|����dS)N)r�r�)�c)rrr�rr�innerRs
z7ExceptionTests.test_memory_error_cleanup.<locals>.innerzMemoryError not raised)rirr.�assertNotEqualrMr)rr$rQr)rrr�r�test_memory_error_cleanupJs
 
z(ExceptionTests.test_memory_error_cleanupcszGdd�d��d����fdd��y
��Wn0tk
r\}z|j��d�WYdd}~XnX|jd�|j��d�dS)Nc@seZdZdS)z6ExceptionTests.test_recursion_error_cleanup.<locals>.CN)rrrrrrrrcsrcs��}tj|����dS)N)r�r�)r#)rr$r�rrr$fs
z:ExceptionTests.test_recursion_error_cleanup.<locals>.innerzRecursionError not raised)r4r%rMr)rrQr)rr$r�r�test_recursion_error_cleanup`s
 
z+ExceptionTests.test_recursion_error_cleanupcCs:|jt��}tjt�WdQRX|j|jjtj|j�dS)N)	rAr'�os�listdirrrr[r�ENOTDIR)rr_rrr�test_errno_ENOTDIRtsz!ExceptionTests.test_errno_ENOTDIRcCsGdd�d�}Gdd�d|�}Gdd�d�}x�|||fD]�}|j|���|�}t��}~WdQRX|j�}|jd|�||kr�|jd|�n|j|jj|�|jd	|�|jd
|�||kr�|jd|�|jd|�n|jd
|�|jd|�|j|jd��WdQRXq8WdS)Nc@seZdZdd�ZdS)z1ExceptionTests.test_unraisable.<locals>.BrokenDelcSstd�}|�dS)Nz
del is broken)r<)rrrrrr}sz9ExceptionTests.test_unraisable.<locals>.BrokenDel.__del__N)rrrrrrrr�	BrokenDel|sr,c@seZdZdd�ZdS)z2ExceptionTests.test_unraisable.<locals>.BrokenReprcSstd��dS)Nzrepr() is broken)r")rrrr�__repr__�sz;ExceptionTests.test_unraisable.<locals>.BrokenRepr.__repr__N)rrrr-rrrr�
BrokenRepr�sr.c@seZdZdd�ZdS)z:ExceptionTests.test_unraisable.<locals>.BrokenExceptionDelcSst�}|�dS)N)r)rrrrrr�szBExceptionTests.test_unraisable.<locals>.BrokenExceptionDel.__del__N)rrrrrrrr�BrokenExceptionDel�sr/zException ignoredz<object repr() failed>ztest_exceptions.pyz	raise excrz<exception str() failed>r<z
del is broken�
)�subTestr�getvaluer�rrrorq)rr,r.r/Z
test_classr�r��reportrrr�test_unraisablezs*zExceptionTests.test_unraisablecCs�x�ttfD]�}|j|���y|d�}|�Wn4|k
r^t��}tjtj��WdQRXYnX|j�}|jd|�|jd|�|j|j	|�|tkr�|jd|�n|jd|�|j
|jd��WdQRXq
WdS)Nztest messageztest_exceptions.pyz	raise excz<exception str() failed>r0)r<rr1rrC�__excepthook__rkr2r�rrorq)rr�rr�r3rrr�test_unhandled�s zExceptionTests.test_unhandledcCsJd}x@tdd�D]2}tjd||�\}}}|j|d�|jd|�qWdS)Nz�if 1:
            import _testcapi
            class C(): pass
            _testcapi.set_nomemory(0, %d)
            C()
        r1rdz-c�xsMemoryError)r1r7)rKrrr�)rr�r�rrr rrr�"test_memory_error_in_PyErr_PrintEx�s
z1ExceptionTests.test_memory_error_in_PyErr_PrintExN)9rrrr!rRrZr\rerrwr��unittestZ
skipUnlessrCrWr�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�rrrrrrrrr"r&r'r+r4r6r8rrrrrsbT
0'	~


t

%;('rc@s$eZdZdd�Zdd�Zdd�ZdS)�ImportErrorTestsc(CsVtd�}|j|j�|j|j�tddd�}|j|jd�|j|j�tddd�}|j|jd�|j|j�tdddd�}|j|jd�|j|jd�d}|jt|��tdd	d
�WdQRX|jt|��tddd	d�WdQRX|jt|��tdd
d	d�WdQRX|jt|��td	d
�WdQRX|jt|��tdd	dd�WdQRXdS)N�testZ
somemodule)�name�somepath)�path�somename)r>r<z:'invalid' is an invalid keyword argument for this function�keyword)�invalidr<)r<rAr>)r>rAT)rAZanother)r(r�r<r>rr�r;)rrrSrrr�test_attributes�s.z ImportErrorTests.test_attributescCs@tdtfdd��&d}t|�}|jt|�t|��WdQRXdS)NrT)�quietsabc)r�BytesWarningr(rr)r�argrrrr�test_non_str_argument�sz&ImportErrorTests.test_non_str_argumentcCs�x�t�tdd�tdd�tddd�fD]�}td|�}xdttjd�D]R}tjtj||��}|j|jd	�|j|j	d�|j|j
|j
�|j|j|j�qBWxXtjtj
fD]H}||�}|j|jd
�|j|j	d�|j|j
|j
�|j|j|j�q�Wq$WdS)Nr?)r<r=)r>)r<r>r;r1)r;)r;)r;)�dictr(rKr�r�rHr�rr�rSr<r>�copy�deepcopy)r�kwargsZorig�protorr#rrr�test_copy_pickle�s"
z!ImportErrorTests.test_copy_pickleN)rrrrBrFrLrrrrr:�s"r:�__main__)rHr(rCr9r�r�rZtest.supportrrrrrrrr	r
rrr
rrrrZTestCaserr:r�mainrrrr�<module>s.83?

Youez - 2016 - github.com/yon3zu
LinuXploit