Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_exceptions.cpython-39.opt-1.pyc

a

��gA��@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	m
Z
mZmZm
Z
mZmZmZmZmZmZddlmZGdd�de�ZGdd�de�ZGdd	�d	e�ZGd
d�dej�ZGdd
�d
ej�Zedkr�e��dS)�N)�TESTFN�captured_stderr�check_impl_detail�check_warnings�cpython_only�
gc_collect�
no_tracing�unlink�
import_module�
script_helper�SuppressCrashReport)�supportc@seZdZdd�ZdS)�NaiveExceptioncCs
||_dS�N��x��selfr�r�0/usr/local/lib/python3.9/test/test_exceptions.py�__init__szNaiveException.__init__N��__name__�
__module__�__qualname__rrrrrrsrc@seZdZdZdd�ZdS)�SlottedNaiveExceptionrcCs
||_dSrrrrrrrszSlottedNaiveException.__init__N)rrr�	__slots__rrrrrrsrc@seZdZdd�ZdS)�BrokenStrExceptioncCstd��dS)Nzstr() is broken)�	Exception�rrrr�__str__szBrokenStrException.__str__N)rrrr rrrrrsrc@sLeZdZdd�Zdd�Zdd�Zdd�Zd�d
d�Zdd
�Zdd�Z	e
dd��Zdd�Ze
�ejdkd�dd��Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zed(d)��Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Z d4d5�Z!d6d7�Z"d8d9�Z#d:d;�Z$d<d=�Z%d>d?�Z&d@dA�Z'dBdC�Z(dDdE�Z)dFdG�Z*dHdI�Z+dJdK�Z,dLdM�Z-dNdO�Z.dPdQ�Z/dRdS�Z0dTdU�Z1dVdW�Z2dXdY�Z3edZd[��Z4e
d\d]��Z5e
d^d_��Z6e
d`da��Z7dbdc�Z8e
ddde��Z9e
dfdg��Z:e
dhdi��Z;e
djdk��Z<edldm��Z=dndo�Z>dpdq�Z?drds�Z@e
dtdu��ZAdvdw�ZBdxdy�ZCdzd{�ZDe
�d|d}�d~d��ZEd�d��ZFd�S)��ExceptionTestscCs�|j||d���z|d��Wn,|yH}zt|�}WYd}~n
d}~00z|d��Wn,|y�}zt|�}WYd}~n
d}~00|�||�|�|j|�Wd�n1s�0YdS)N)�exc�excnameZspam)�subTest�str�assertEqualr)rr"r#�errZbuf1Zbuf2rrr�raise_catch$szExceptionTests.raise_catchc
Cs|�td�|�tttd�|�td�ttd�}|��ttd�}tj	}zDzddl
}|�d�WntytYn0W|t_	|��tt�n|t_	|��tt�0|�t
d�|�t
td	d�|�td
�|�ttd�|�td�g}|�t|jd
�|�td�i}|�t|jd�|�td�|�td�|�td�zt}Wnt�y^Yn0|�td�d}td�D]}||7}�qx|�td�|�td�|�td�ztd�Wnt�y�Yn0|�td�|�td�ztddd�Wnt�y
Yn0|� d�|�t!d �|�t"d!�|�t"tj#d�|�t$d"�zgd#Wnt$�yjYn0|�t%d$�|�t%t&d%�|�t'd&�zdd}Wnt'�y�Yn0|�t(d'�zdd}Wn&t(�y�}zWYd}~n
d}~00|�t)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�	TypeErrorr�
ValueErrori�ZeroDivisionErrorr�StopAsyncIteration)*r(r)�assertRaises�getattr�sysr*�openr�close�stdin�marshal�loadsr	r.r/�
__import__r0�__getitem__r2r4r5r6Zundefined_variabler7�ranger:r;r<r?r=r>�compile�failr@rA�exitrBrC�chrrDrrE)r�fpZ	savestdinrLr�dummy�errr�testRaising1s�


�

�
&zExceptionTests.testRaisingcs(�fdd�}d}||d�|dd�dS)Ncs��j||d��nzt|dd�WnBtyb}z*|j|krN��d||jf�WYd}~nd}~00��d�Wd�n1s�0YdS)N)�src�msg�
<fragment>r?�expected %s, got %s�"failed to get expected SyntaxError)r$rQr<rZrR)rYrZrWrrr�ckmsg�s
*z4ExceptionTests.testSyntaxErrorMessage.<locals>.ckmsgzHif 1:
        try:
            continue
        except:
            passz'continue' not properly in loopz	continue
r�rr^�srrr�testSyntaxErrorMessage�s

z%ExceptionTests.testSyntaxErrorMessagecs^tf�fdd�	}d}||d�d}||d�d}||d�d	}||d
t�d}||dt�dS)
Nc
sbzt|dd�WnB|yR}z*|j|kr>��d||jf�WYd}~nd}~00��d�dS)Nr[r?r\r])rQrZrR)rYrZ�	exceptionrWrrrr^�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)r<r=r>r_rrr�testSyntaxErrorMissingParens�s	


z+ExceptionTests.testSyntaxErrorMissingParens�utf-8c	Cs�|j|||d���|�t��}t|dd�Wd�n1s>0Y|�|jj|�|�|jj|�|jjdur�t	|t
�s�|�|d�}|�d�|d}|�
||jj�Wd�n1s�0YdS)N)�source�lineno�offsetr[r?�replace�
r8)r$rFr<rQr&rbrfrg�text�
isinstancer%�decode�split�assertIn)rrYrfrg�encoding�cm�linerrr�check�s*
zExceptionTests.checkcCs|j}|ddd�dS)Nz"\
"(1 for c in I,\
\��)rr�rrrrrr�)test_error_offset_continuation_characters�sz8ExceptionTests.test_error_offset_continuation_characterscCs@|j}|ddd�|ddd�|ddd�|d	dd
�|ddd
�|ddd
dd�|ddd�|ddd�|ddd�|ddd�|ddd�|ddd�|ddd�|ddd�|ddd�|ddd�|ddd�|ddd �|d!dd�|d"dd�|d#dd�|d$ddd%d�|d&d'd
�|d(dd�|d)dd�|d*d+t���rNd+nd,�|d-dd.�|d/dd�|d0dd�|d1dd�|d2dd�|d3dd�|d4dd�|d5dd�|d6dd�|d7dd�|d8dd.�|d9dd�|d:dd�|d;dd.�|d<dt���rdnd�|d=dt���r*dnd �|d>dd.�dS)?Nzdef fact(x):
	return x!
�r1z1 +
r8�z def spam():
  print(1)
 print(2)rszPython = "Python" +�uPython = "Ṕýţĥòñ" +s+# -*- coding: cp1251 -*-
Python = "ϳ���" +��cp1251)rosPython = "ϳ���" +�zx = "a�zlambda x: x = 2zf{a + b + c}zclass foo:return 1�zdef f():
  continuezdef f():
  breakz4try:
  pass
except:
  pass
except ValueError:
  passz(0x+1)zx = 0xI�z0010 + 2z
x = 32e-+4�zx = 0o9uα = 0xIsα = 0xIs## -*- coding: iso8859-7 -*-
� = 0xIz	iso8859-7s�if 1:
            def foo():
                '''

            def bar():
                pass

            def baz():
                '''quux'''
            �	z"pass
pass
pass
(1+)
pass
pass
passz(1+)s#coding: utf8
print('我')
r���z!x = [(yield i) for i in range(3)]�zdef f():
  from _ import *zdef f(x, x):
  passzdef f(x):
  nonlocal xzdef f(x):
  x = 1
  global xz
nonlocal xz def f():
  global x
  nonlocal xz#from __future__ import doesnt_existzfrom __future__ import bracesz#x=1
from __future__ import divisionzfoo(1=2)zdef f():
  x, y: intz[*x for x in xs]zfoo(x for x in range(10), 100)z
(yield i) = 2zdef f(*):
  passzfor 1 in []: pass)rrr
Zuse_old_parserrurrr�testSyntaxErrorOffset�sh��	�
�z$ExceptionTests.testSyntaxErrorOffsetcsjGdd�dt��Gdd�d����fdd�}��fdd�}��fd	d
�}tj�d�sf|�|�|�dS)Nc@seZdZdd�ZdS)z9ExceptionTests.testSettingException.<locals>.BadExceptioncSstd��dS)Nzcan't instantiate BadException)r:)Zself_rrrrszBExceptionTests.testSettingException.<locals>.BadException.__init__Nrrrrr�BadExceptionsr�c@seZdZdS)z=ExceptionTests.testSettingException.<locals>.InvalidExceptionN�rrrrrrr�InvalidExceptionsr�c
s�ddl}z|��d�WnZtyr}zBt��\}}}|jj}��|jd���	|j
�d��WYd}~nd}~00��d�dS)Nrr8�
test_capi1�test_exceptions.py�Expected exception)
�	_testcapi�raise_exceptionrBrH�exc_info�tb_frame�f_coder&�co_name�
assertTrue�co_filename�endswithrR)r�r'r"�tb�co�r�rrrr�s(z7ExceptionTests.testSettingException.<locals>.test_capi1c
s�ddl}z|��d�Wnrty�}zZt��\}}}|jj}��|jd���	|j
�d��|jjj}��|jd�WYd}~nd}~00��
d�dS)Nrrr��
test_capi2r�)r�r�r:rHr�r�r�r&r�r�r�r��f_backrR)r�r'r"r�r�Zco2r�rrr�"s
$z7ExceptionTests.testSettingException.<locals>.test_capi2csddl}��t|j�d�dS)Nrr8)r�rFr@r�)r�)r�rrr�
test_capi30s
�z7ExceptionTests.testSettingException.<locals>.test_capi3�java)rrH�platform�
startswith)rr�r�r�r)r�r�rr�testSettingException
sz#ExceptionTests.testSettingExceptioncCs�ztWntyY�n�0|�tt�|�ttd��d�|�ttdd��d�tddd�}|�|jd�|�|jd�|�t|�d�td	ddd
�}|�|jd�|�|jd
�|�|jd�|�|j	d�|�|j
d�|�t|�d�td	ddd�}|�|jd
�|�|jd�|�|jd�|�|j	d�|�|j
d�|�t|�d�tdd�}|�|jd�|�|jd�|�|jd�|�|j	d�|�|j
d�dS)Ni�Z1001�messagez[Errno 1001] messager��foo�barz[Errno 9] foo: 'bar'rrsrwz[WinError 3] foo: 'bar'rtz[WinError 1001] foo)�WindowsErrorr6�assertIsr.r&r%�errno�winerror�strerror�filename�	filename2)rr+rrr�test_WindowsError:sB�
z ExceptionTests.test_WindowsError�win32ztest specific to WindowscCsLtd�}d}|�td|��|j�|�Wd�n1s>0YdS)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_messageasz#ExceptionTests.test_windows_messagecCs
tdddiftdddiftdddiftdddiftdddd�ftddddddd�ftd	d	dddd
d�ftdd	dddd
d�ftd
d	ddd�ftdddddd�ftddddddd�ftdddddddd�ftddddddddd�ftddd ddddd!d"�ftd#dd#dddddd$�ftdddiftd%d%d&d'd(d)d*�ftd&td+�d(dd)fd&td+�d(dd)fd&d+d(d)d*�ftd,d,d&d+d(d)d*�ftd-d-d.d/d(dd0�ft	dddd1�ft
dddd1�fg}z"|�tdddddddd2�f�Wnt
�y�Yn0|D�] \}}}z||�}Wn$td3||ftjd4��Yn�0t|�j�d5��sD|�t|�jd6�t|�}|D]:}t||�}|�t|�t||�d7|||||f��qPtfD]n}	t|	jd�D]X}
|	�||
�}|	�|�}|D]6}tt||��}t||�}
|�||
d8||f��qq��q��q�dS)9Nr�args)r8)r�)r�r8r�)r�r�)r�r�r�r�r�)r�r�r�)r�r��bazr�)r�r�r�N�quuxr�)r�r�r�)�errnoStr�strErrorStr�filenameStr)r�r�r�r�r�)r�r�r�r�)r8r�r�)r8r�r8)r�r�r�r�r�)rZrjr�rfrg�print_file_and_line)�msgStrr�)r�rjr�rZr�rfrg)r�)r��	linenoStr�	offsetStr�textStrr�r�r�)rgrjr�r�rZr�rf)r�r�r�r�r�Zprint_file_and_lineStr)rjr�r�rZr�rfrg)�ascii�arr8�ordinal not in ranger�r�rr�)r�ro�object�start�reason��)r�r�rr8r�)�あrr8�ouchr�r�)r�r�r�r��end)r�r)r�r�r�r�r�r�z
exc=%r, args=%r)�filer�builtinsz%r.%s == %r, expected %rzpickled "%r", attribute "%s)�
BaseExceptionrAr.r<�UnicodeError�UnicodeEncodeError�UnicodeDecodeError�	bytearray�UnicodeTranslateErrorrr�appendr�r6�printrH�stderr�typerr�r&rr%rG�repr�picklerP�HIGHEST_PROTOCOL�dumpsrM)rZ
exceptionListr"r�ZexpectedrWr`ZcheckArgName�value�p�protocol�newZgotZwantrrr�testAttributesks"���������
�������������������������O���


��

��zExceptionTests.testAttributescCs�ztd��Wnt��d}Yn0t��|�}|�|t�|�|j|�td��|�}|�|t�|�|j|�Gdd�dt�}|��|�}|�||�|�|j|�dS)Nrxrwr�c@seZdZdS)z5ExceptionTests.testWithTraceback.<locals>.MyExceptionNr�rrrr�MyException�sr�)	r0rHr�r��with_traceback�assertIsInstancer&�
__traceback__r)rr�rWr�rrr�testWithTraceback�sz ExceptionTests.testWithTracebackc
CsPzdt�_Wn4ty@}z|�dt|��WYd}~nd}~00|�d�dS)Nr�z!__traceback__ must be a tracebackzNo exception raised)rr�rBrnr%rR�rrWrrr�testInvalidTraceback�s
&z#ExceptionTests.testInvalidTracebackcCsP|�ttt�dd�|�ttt�d�|�ttt�dd�|�ttt�d�dS)N�	__cause__r8�__context__)rFrB�setattrr�delattrrrrr�testInvalidAttrsszExceptionTests.testInvalidAttrscCsJztd��Wnt��d}Yn0t�}||_d|_|�|jd�dS)Nrxrw)r0rHr�rr�r&)rr�rWrrr�testNoneClearsTracebackAttrsz*ExceptionTests.testNoneClearsTracebackAttrcCsnt�}|�|j�|�|j�t�}|�|j�|�|j�Gdd�dt�}|�}|�|j�|�|j�dS)Nc@seZdZdS)z5ExceptionTests.testChainingAttrs.<locals>.MyExceptionNr�rrrrr� sr�)r�assertIsNoner�r�rBr.)rrWr�rrr�testChainingAttrssz ExceptionTests.testChainingAttrsc
Cs�z
t��Wn(ty2}z|}WYd}~n
d}~00|�|j�|�|j�|�|j�t�|_d|_|�|jt�|�|j�|�|j�d|_|�|j�dS)NF)	rr�r�r�ZassertFalse�__suppress_context__r6r�r�)rr"rWrrr�testChainingDescriptors's
z&ExceptionTests.testChainingDescriptorscCs<|jttdd�Gdd�dt�}|dd�}|�|jd�dS)Nr8)r�c@seZdZdd�ZdS)z8ExceptionTests.testKeywordArgs.<locals>.DerivedExceptioncSst�|�||_dSr)r�r�	fancy_arg)rr�rrrr?s
zAExceptionTests.testKeywordArgs.<locals>.DerivedException.__init__Nrrrrr�DerivedException>sr��*)r�)rFrBr�r&r�)rr�rrrr�testKeywordArgs9s
zExceptionTests.testKeywordArgscs4�fdd��|�t���fdd��|�t��dS)Ncs��Srrr)�frrr�Hsz/ExceptionTests.testInfiniteRecursion.<locals>.fcs"z��WStyYdS0dS)Nr��rCr��grrr�Lsz/ExceptionTests.testInfiniteRecursion.<locals>.g)rFr;rr)r�r�r�testInfiniteRecursionFsz$ExceptionTests.testInfiniteRecursioncCs8|�tt��|�ttd���|�ttdd���dS)Nr��b)r�r%rrrrr�test_strSszExceptionTests.test_strc
Cs|z
t��Wn0ty:}z|�|t�WYd}~n
d}~00|�dt��|�t��|Wd�n1sn0YdS�NrW�rr�ZassertNotIn�localsrF�UnboundLocalErrorr�rrr�test_exception_cleanup_namesYs
"z+ExceptionTests.test_exception_cleanup_namesc
Cs~z
t��Wn2ty<}z|�|t�~WYd}~n
d}~00|�dt��|�t��|Wd�n1sp0YdSr�r�r�rrr�test_exception_cleanup_names2ds
z,ExceptionTests.test_exception_cleanup_names2cs�Gdd�dt��Gdd�d�}��fdd�}|��t���}z
|�Wn$�yj}zWYd}~n
d}~00d�t�|��|���|��t���}z
|�Wn�y�Yn0d�t�|��|���|��t���}z
|�WnYn0d�t�|��|���|��t���}dD]&}z
|�WnY�qLYn0�q$d�t�|��|���|��t���}z z
|�Wnt�Yn0WnXt�y�}z>d|_d�t�|��tdd	��r�t�|���WYd}~n
d}~00|��t���}z
|�Wn<��yFzz�W�n�0Wn��y@Yn0Yn0d�tdd	��r^t�|��|���Gd
d�d�}|��t���}|��|�Wd�n1�s�0Yd�tdd	��r�t�|��|���dS)Nc@seZdZdd�ZdS)z=ExceptionTests.testExceptionCleanupState.<locals>.MyExceptioncSs
||_dSr��obj�rr�rrrrtszFExceptionTests.testExceptionCleanupState.<locals>.MyException.__init__Nrrrrrr�ssr�c@seZdZdS)z7ExceptionTests.testExceptionCleanupState.<locals>.MyObjNr�rrrr�MyObjvsr�cs�}����dSrr)Z	local_ref�r�r�rr�inner_raising_funcyszDExceptionTests.testExceptionCleanupState.<locals>.inner_raising_func)rF)Zcpythonc@seZdZdd�Zdd�ZdS)z9ExceptionTests.testExceptionCleanupState.<locals>.ContextcSs|Srrrrrr�	__enter__�szCExceptionTests.testExceptionCleanupState.<locals>.Context.__enter__cSsdS)NTr)r�exc_type�	exc_value�exc_tbrrr�__exit__�szBExceptionTests.testExceptionCleanupState.<locals>.Context.__exit__N)rrrrrrrrr�Context�sr)r�weakref�refrr�r2r�r)rr�r��wrrW�irrr�r�testExceptionCleanupStateos�













 



&z(ExceptionTests.testExceptionCleanupStatec
sD�fdd�}ztWn*ty>�z|�WYd��n
d��00dS)Ncs�dSrrr�rWrr�print_error�szIExceptionTests.test_exception_target_in_nested_scope.<locals>.print_error)Z	somethingr)rrrrr�%test_exception_target_in_nested_scope�s
z4ExceptionTests.test_exception_target_in_nested_scopecCs�dd�}|�}|�t|�t�|�t��dd�|�t|�t�|�t��dd�|�t|�d�ztd��Wn�ty�|�}|�t|�t�|�t��dt�|�t|�t�|�t��dt�|�t|�t�~|�t��dt�Yn0dS)NcssNztd��Wn.ty:t��dVt��dVYn0t��dVdS)NZcaughtr)r2rHr�rrrr�yield_raise�sz:ExceptionTests.test_generator_leaking.<locals>.yield_raiserr�)r&�nextr2rHr�rB)rrr�rrr�test_generator_leaking�s$z%ExceptionTests.test_generator_leakingcCsfdd�}zt�Wn ty0|�}t|�Yn0zt|�WntyPYn0|�t��d�dS)Ncss
dVdSrrrrrrr�sz1ExceptionTests.test_generator_leaking2.<locals>.g�NNN)r:r�
StopIterationr&rHr��rr��itrrr�test_generator_leaking2sz&ExceptionTests.test_generator_leaking2c
Cs�dd�}|�}t|�zddWnbty�}zJ|�t��d|�|�|�}|�t��d|�|�||�WYd}~n
d}~00|�t��d�dS)Ncss0z
dVWn ty*t��dVYn0dS�Nr8�rDrHr�rrrrr�#s
z1ExceptionTests.test_generator_leaking3.<locals>.gr8rr)rrDr�rHr��throwr&)rr�rrWZgen_excrrr�test_generator_leaking3 s
"z&ExceptionTests.test_generator_leaking3c
Cs�dd�}|�}zt�Wnty0t|�}Yn0|�|t�zt|�Wn8ty�}z |�t��d|�WYd}~n
d}~00|�t��d�dS)Ncss4zddWn"ty.t��dV�Yn0dS�Nr8rrrrrrr�6s
z1ExceptionTests.test_generator_leaking4.<locals>.gr8r)rBrr�rDrHr�r&)rr�r�tprWrrr�test_generator_leaking43s*z&ExceptionTests.test_generator_leaking4csH�fdd�}|�}zt�Wnty4t|�Yn0��tt|�dS)Nc3s.��t��dt�dV��t��d�dS)Nr8r)r�rHr�r:r&rrrrr�Osz>ExceptionTests.test_generator_doesnt_retain_old_exc.<locals>.g)r:rrFrrrrr�$test_generator_doesnt_retain_old_excNsz3ExceptionTests.test_generator_doesnt_retain_old_exccs4dd���fdd�}|�t�|�t��d�dS)Ncss
dVdSrrrrrr�
simple_gen\szIExceptionTests.test_generator_finalizing_and_exc_info.<locals>.simple_gencs.��}zt�Wnty(t|�YS0dSr)r:r)�gen�rrr�run_gen^s
zFExceptionTests.test_generator_finalizing_and_exc_info.<locals>.run_genr)rr&rHr�)rr!rr r�&test_generator_finalizing_and_exc_infoZs
z5ExceptionTests.test_generator_finalizing_and_exc_infocstGdd�dt��Gdd�d�}��fdd�}|��t���}|�}t|�||�d}�t�|��|���dS)Nc@seZdZdd�ZdS)zFExceptionTests._check_generator_cleanup_exc_state.<locals>.MyExceptioncSs
||_dSrr�r�rrrrlszOExceptionTests._check_generator_cleanup_exc_state.<locals>.MyException.__init__Nrrrrrr�ksr�c@seZdZdS)z@ExceptionTests._check_generator_cleanup_exc_state.<locals>.MyObjNr�rrrrr�nsr�c3s*z����Wn�y$dVYn0dSrrrr�rr�raising_genqszFExceptionTests._check_generator_cleanup_exc_state.<locals>.raising_gen)rrrrrr�)rZtestfuncr�r#rr�rr�r�"_check_generator_cleanup_exc_statehs
z1ExceptionTests._check_generator_cleanup_exc_statecCsdd�}|�|�dS)NcSs(z|�t��Wnty"Yn0dSr)rr:r�rrr�do_throw�szGExceptionTests.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�}|�|�dS)NcSs|��dSr)rJr�rrr�do_close�szGExceptionTests.test_generator_close_cleanup_exc_state.<locals>.do_closer&)rr(rrr�&test_generator_close_cleanup_exc_state�sz5ExceptionTests.test_generator_close_cleanup_exc_statecCsdd�}|�|�dS)NcSsd}dSrrr�rrr�do_del�szCExceptionTests.test_generator_del_cleanup_exc_state.<locals>.do_delr&)rr*rrr�$test_generator_del_cleanup_exc_state�sz3ExceptionTests.test_generator_del_cleanup_exc_statecs�fdd�}��|�dS)Ncs.zt|�WntyYn0��d�dS�Nz should have raised StopIteration)rrrRr�rrr�do_next�s
zEExceptionTests.test_generator_next_cleanup_exc_state.<locals>.do_nextr&)rr-rrr�%test_generator_next_cleanup_exc_state�sz4ExceptionTests.test_generator_next_cleanup_exc_statecs�fdd�}��|�dS)Ncs0z|�d�Wnty Yn0��d�dSr,)�sendrrRr�rrr�do_send�s
zEExceptionTests.test_generator_send_cleanup_exc_state.<locals>.do_sendr&)rr0rrr�%test_generator_send_cleanup_exc_state�sz4ExceptionTests.test_generator_send_cleanup_exc_statecsHG�fdd�d�}d�zt|���WnYn0t�|��d�dS)NcseZdZ�fdd�ZdS)z*ExceptionTests.test_3114.<locals>.MyObjectcst���dSr)rHr�rrrr�__del__�sz2ExceptionTests.test_3114.<locals>.MyObject.__del__N�rrrr2rrrr�MyObject�sr4rr)rrr&)rr4rrr�	test_3114�szExceptionTests.test_3114cCs�Gdd�dt�}Gdd�dt�}Gdd�dt�}z�z|�Wn�|�y}z�|}z|�Wn�|�y}z�|}z|�Wnx|y�}z`|}	|�||�|�||�|�|	|�|�|j�|�|j|�|�|	j|�|�WYd}~n
d}~00WYd}~n
d}~00WYd}~n
d}~00Wn*|�yH}
z|
}WYd}
~
n
d}
~
00|�||�|�|j|	�|�|	j|�|�|j�dS)Nc@seZdZdS)zHExceptionTests.test_raise_does_not_create_context_chain_cycle.<locals>.ANr�rrrr�A�sr6c@seZdZdS)zHExceptionTests.test_raise_does_not_create_context_chain_cycle.<locals>.BNr�rrrr�B�sr7c@seZdZdS)zHExceptionTests.test_raise_does_not_create_context_chain_cycle.<locals>.CNr�rrrr�C�sr8)rr�r�r�r�)rr6r7r8Za_r�Zb_r�Zc_�crWr"rrr�.test_raise_does_not_create_context_chain_cycle�s:Jz=ExceptionTests.test_raise_does_not_create_context_chain_cyclec
Csldd�}z
|�Wn(ty:}z|}WYd}~n
d}~00|�|t�|�|jt�|�|jj|j�dS)Nc
SsDztd��Wn2ty>}z||_td��WYd}~n
d}~00dS�Nr8rw)rCr�rB)�exrrr�cycle�s
zBExceptionTests.test_no_hang_on_context_chain_cycle1.<locals>.cycle)rr�rBr�rCr�)rr=rWr"rrr�$test_no_hang_on_context_chain_cycle1�s
z3ExceptionTests.test_no_hang_on_context_chain_cycle1cCs<Gdd�dt�}Gdd�dt�}Gdd�dt�}|�|���}z
|��Wn�|y�}z�|}z
|��Wnf|y�}zN|}z
|��Wn2|y�}	z|	}
|
|_|
�WYd}	~	n
d}	~	00WYd}~n
d}~00WYd}~n
d}~00Wd�n1s�0Y|�|j|
�|�|
j|�|�|j|�|�|j|
�dS)Nc@seZdZdS)z>ExceptionTests.test_no_hang_on_context_chain_cycle2.<locals>.ANr�rrrrr6�sr6c@seZdZdS)z>ExceptionTests.test_no_hang_on_context_chain_cycle2.<locals>.BNr�rrrrr7�sr7c@seZdZdS)z>ExceptionTests.test_no_hang_on_context_chain_cycle2.<locals>.CNr�rrrrr8�sr8�rrFr�r�rb)rr6r7r8rp�_ar��_br��_cr9rrr�$test_no_hang_on_context_chain_cycle2�s,


dz3ExceptionTests.test_no_hang_on_context_chain_cycle2cCs�Gdd�dt�}Gdd�dt�}Gdd�dt�}Gdd�dt�}Gd	d
�d
t�}|�|���}z
|��Wn�|�y@}z�|}z
|��Wn�|�y*}	z�|	}
z
|��Wnn|�y}zT|}||_z
|��Wn2|y�}
z|
}|�}|�WYd}
~
n
d}
~
00WYd}~n
d}~00WYd}	~	n
d}	~	00WYd}~n
d}~00Wd�n1�sX0Y|�|j|�|�|j|�|�|j|�|�|j|
�|�|
j|�|�|j|�dS)Nc@seZdZdS)z>ExceptionTests.test_no_hang_on_context_chain_cycle3.<locals>.ANr�rrrrr6sr6c@seZdZdS)z>ExceptionTests.test_no_hang_on_context_chain_cycle3.<locals>.BNr�rrrrr7sr7c@seZdZdS)z>ExceptionTests.test_no_hang_on_context_chain_cycle3.<locals>.CNr�rrrrr8sr8c@seZdZdS)z>ExceptionTests.test_no_hang_on_context_chain_cycle3.<locals>.DNr�rrrr�DsrDc@seZdZdS)z>ExceptionTests.test_no_hang_on_context_chain_cycle3.<locals>.ENr�rrrr�E srEr?)rr6r7r8rDrErpr@r�rAr�rBr9Z_d�drWrrr�$test_no_hang_on_context_chain_cycle3s>



|z3ExceptionTests.test_no_hang_on_context_chain_cycle3cCsftddddd�}|�t|�d�d|_|�t|�d�d|_d	|_|�t|�d
�d|_|�t|�d�d
|_|�t|�d�tddddd�}|�t|�d�d|_|�t|�d�d|_d	|_|�t|�d�d|_|�t|�d�d
|_|�t|�d�tdddd�}|�t|�d�d|_|�t|�d�d|_d	|_|�t|�d�d
|_|�t|�d�dS)Nr�Zxxxxxr8r�r�z8'baz' codec can't encode characters in position 1-4: foorwz<'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�r&r%r�r�ror�r�r�)r�urrr�test_unicode_change_attributesDs>z-ExceptionTests.test_unicode_change_attributescCs.tttf}|D]}|�t|�|��d�qdS)N�)r�r�r�r&r%�__new__)rZklasses�klassrrr�test_unicode_errors_no_objectis
z,ExceptionTests.test_unicode_errors_no_objectcs�Gdd�dt�}Gdd�dt|d�}t��x}z
t��WnR|yd}z|�d�WYd}~n8d}~0tytYn |�d�Yn0|�d�Wd�n1s�0Y�fdd	����\}}}|�|tt|��|�d
t|��dS)Nc@seZdZdd�ZdS)z/ExceptionTests.test_badisinstance.<locals>.MetacSs
t��dSrr�)�cls�subclassrrr�__subclasscheck__tszAExceptionTests.test_badisinstance.<locals>.Meta.__subclasscheck__N)rrrrPrrrr�MetassrQc@seZdZdS)z6ExceptionTests.test_badisinstance.<locals>.MyExceptionNr�rrrrr�vsr�)�	metaclassz%exception should not be a MyExceptionzShould have raised KeyErrorcs(z��WSty"t��YS0dSr)r;rHr�rr�rrr��sz,ExceptionTests.test_badisinstance.<locals>.gz maximum recursion depth exceeded)	r�rrr2rRr�r;rnr%)rrQr�r�rW�vr�rr�r�test_badisinstanceos 
(z!ExceptionTests.test_badisinstancecCsdd�}|�t��dS)NcSst�}td�D]
}|j}qdS)Ni@B)r�rP�__dir__)�orrrrr��sz3ExceptionTests.test_trashcan_recursion.<locals>.foo)r
r)rr�rrr�test_trashcan_recursion�sz&ExceptionTests.test_trashcan_recursioncCsPdt}t�dd|�\}}}|�|d�|�d|�|�d|�|�d|�dS)Na�if 1:
            import sys
            from _testinternalcapi 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)
            finally:
                sys.setrecursionlimit(recursionlimit)
                print('Done.')
        z-Wd�-cr8sRecursionErrorsResourceWarning�Done.)�__file__r�assert_python_failurer&rn�rr��rc�outr'rrr�$test_recursion_normalizing_exception�s(�)z3ExceptionTests.test_recursion_normalizing_exceptioncCs>d}t�d|�\}}}|�|d�|�d|�|�d|�dS)Nz�if 1:
            import _testcapi
            try:
                raise _testcapi.RecursingInfinitelyError
            finally:
                print('Done.')
        rXr8sORecursionError: maximum recursion depth exceeded while normalizing an exceptionrY)rr[r&rnr\rrr�-test_recursion_normalizing_infinite_exception�s�z<ExceptionTests.test_recursion_normalizing_infinite_exceptionc
s�dd�}�fdd���fdd���fdd��t��}zz|d	����fD]X}|j|d
��8z
|�WntyvYn0|�d�Wd�qH1s�0YqHWt�|�nt�|�0dS)NcSsDd}zt�|�Wq2ty,|d7}Yq0q2qt�||�dSr)rH�setrecursionlimitr;)�n�depthrrr�set_relative_recursion_limit�szUExceptionTests.test_recursion_in_except_handler.<locals>.set_relative_recursion_limitcs$zddWn��Yn0dSrrr)�recurse_in_exceptrrre�szJExceptionTests.test_recursion_in_except_handler.<locals>.recurse_in_exceptcs$zddWnYn0��dSrrr)�recurse_after_exceptrrrf�s
zMExceptionTests.test_recursion_in_except_handler.<locals>.recurse_after_exceptcs"z
��Wn��Yn0dSrrr)�recurse_in_body_and_exceptrrrgs
zSExceptionTests.test_recursion_in_except_handler.<locals>.recurse_in_body_and_exceptr1)�funcz#Should have raised a RecursionError)rH�getrecursionlimitr$r;rRra)rrdZrecursionlimitrhr)rfrgrer� test_recursion_in_except_handler�s
,z/ExceptionTests.test_recursion_in_except_handlercCsLd}t��.t�d|�\}}}|�d|�Wd�n1s>0YdS)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)
        rXsmFatal Python error: _PyErr_NormalizeException: Cannot recover from MemoryErrors while normalizing exceptions.)rrr[rnr\rrr�)test_recursion_normalizing_with_no_memorys�z8ExceptionTests.test_recursion_normalizing_with_no_memorycs@ddl�ddlm����fdd�}|�}|�}��||�dS)Nr��raise_memoryerrorc
sJz
��Wn*ty4}z|j}WYd}~nd}~00��d���|�S)Nz Should have raises a MemoryError)r5r�rR�	format_tb)rWr��rmr�	tracebackrr�
raiseMemError6s

z6ExceptionTests.test_MemoryError.<locals>.raiseMemError)rpr�rmr&)rrqZtb1Ztb2rror�test_MemoryError0s	zExceptionTests.test_MemoryErrorc
Cs"ddl}d}d}|�t|jd�|�d�}|�t|�t�|�t|t��|�	|j
�|�d|�}|�|j
|�|jd|d�}|�t||��Gd	d
�d
t�}|�d|||f�}|�t||��|�t||��|�|j
|�|�dd
|ddi�}	|�t|	|��|�|	j
d�|�|	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>.CNr�rrrrr8\sr8z_testcapi.error4z_testcapi.error5rJr�r8)r�rFr@Zmake_exception_with_docr�r�r��
issubclassrr��__doc__r&r�r�)
rr�Zdoc2Zdoc4rsZerror2Zerror3r8Zerror4Zerror5rrr�test_exception_with_docCs:
�
���z&ExceptionTests.test_exception_with_docc
s�ddlm�Gdd�d��d����fdd�}z
|�Wn2tyj}z|���d�WYd}~nd}~00|�d�t�|���d�dS)Nrrlc@seZdZdS)z3ExceptionTests.test_memory_error_cleanup.<locals>.CNr�rrrrr8psr8cs��}t�|����dSr�rr�r9�r8rmrrr�innerss
z7ExceptionTests.test_memory_error_cleanup.<locals>.innerzMemoryError not raised)r�rmr5�assertNotEqualrRrr&)rr{rWrrzr�test_memory_error_cleanupks
$
z(ExceptionTests.test_memory_error_cleanupc
s�Gdd�d��d����fdd��z
��Wn2ty^}z|���d�WYd}~nd}~00|�d�t�|���d�dS)Nc@seZdZdS)z6ExceptionTests.test_recursion_error_cleanup.<locals>.CNr�rrrrr8�sr8cs��}t�|����dSrrxry�r8r{rrrr{�s
z:ExceptionTests.test_recursion_error_cleanup.<locals>.innerzRecursionError not raised)r;r|rRrr&r�rr~r�test_recursion_error_cleanup�s
$
z+ExceptionTests.test_recursion_error_cleanupcCsN|�t��}t�t�Wd�n1s*0Y|�|jjtj|j�dSr)	rFr.�os�listdirrZr&rbr��ENOTDIR)rrprrr�test_errno_ENOTDIR�s(z!ExceptionTests.test_errno_ENOTDIRcCshGdd�d�}|�}t���8}~t�|�|jj|j�|�|jj�Wd�n1sZ0YdS)Nc@seZdZdd�ZdS)z1ExceptionTests.test_unraisable.<locals>.BrokenDelcSstd�}|�dS)Nz
del is brokenr��rr"rrrr2�sz9ExceptionTests.test_unraisable.<locals>.BrokenDel.__del__Nr3rrrr�	BrokenDel�sr�)	r
Zcatch_unraisable_exceptionrr&Z
unraisabler�r2ZassertIsNotNone�
exc_traceback)rr�r�rprrr�test_unraisable�s
zExceptionTests.test_unraisablec
Cs�ttfD]�}|�|���z|d�}|�WnF|ynt��}tjt���Wd�n1s`0YYn0|��}|�d|�|�d|�|�|j	|�|tur�|�d|�n|�d|�|�
|�d��Wd�q1s�0YqdS)Nztest messager�z	raise excz<exception str() failed>ri)rCrr$rrH�__excepthook__r��getvaluernrr�r�)rrr"r��reportrrr�test_unhandled�s 2zExceptionTests.test_unhandledcCsFd}tdd�D]2}t�d||�\}}}|�|d�|�d|�qdS)Nz�if 1:
            import _testcapi
            class C(): pass
            _testcapi.set_nomemory(0, %d)
            C()
        r8ryrX)r8�xsMemoryError)rPrr[rn)rr�r	r]r^r'rrr�"test_memory_error_in_PyErr_PrintEx�s

z1ExceptionTests.test_memory_error_in_PyErr_PrintExcsxGdd�dt��Gdd�dt����fdd�}|�}|�d�|����|����Wd�n1sj0YdS)Nc@seZdZdS)zBExceptionTests.test_yield_in_nested_try_excepts.<locals>.MainErrorNr�rrrr�	MainError�sr�c@seZdZdS)zAExceptionTests.test_yield_in_nested_try_excepts.<locals>.SubErrorNr�rrrr�SubError�sr�c3sBz
���Wn2�y<z
dVWn�y4Yn0�Yn0dSrrr�r�r�rr�main�s

z=ExceptionTests.test_yield_in_nested_try_excepts.<locals>.main)rr/rFr)rr��cororr�r� test_yield_in_nested_try_excepts�s

z/ExceptionTests.test_yield_in_nested_try_exceptscsR�fdd�}|�}zt�Wn"ty<��t|�d�Yn0��t|�d�dS)Nc3s<zt�Wnty dVYn0��t��d�dVdS)Nr8rrw)rCr&rHr�rrrrr��sz?ExceptionTests.test_generator_doesnt_retain_old_exc2.<locals>.gr8rw)r0r&r)rr�rrrr�%test_generator_doesnt_retain_old_exc2�sz4ExceptionTests.test_generator_doesnt_retain_old_exc2cCsfdd�}|�t��@|�}zddWnt|�t|�Yn0Wd�n1sX0YdS)NcssdV�dVdSr;rrrrrr��sz1ExceptionTests.test_raise_in_generator.<locals>.gr8r)rFrDr)rr�r	rrr�test_raise_in_generator�sz&ExceptionTests.test_raise_in_generatorFz Won't work if __debug__ is Falsec
Cs\tazWnBtyJ}z*b|�|t�|�t|�d�WYd}~nd}~00b|�d�dS)NZhellor�)rB�AssertionErrorr�r�r&r%rRr�rrr�test_assert_shadowings&z$ExceptionTests.test_assert_shadowingcCs�Gdd�dt�}zt�Wn(ty@}z|}WYd}~n
d}~00z|�Wnty\Yn0td�D]8}zt�Wn$ty�}zWYd}~n
d}~00t�qfdS)Nc@seZdZdS)zBExceptionTests.test_memory_error_subclasses.<locals>.TestExceptionNr�rrrr�
TestException$sr�r1)r5rrPr)rr�r"�inst�_rrr�test_memory_error_subclassess	z+ExceptionTests.test_memory_error_subclassesN)rd)Grrrr(rXrarcrrrvr�rr�r��unittestZ
skipUnlessrHr�r�r�r�r�r�r�r�r�r�rr�r�r�r�r
r
rrrrrr"r$r'r)r+r.r1r5r:r>rCrGrIrMrTrWr_r`rjrkrrrwr}rr�r�r�r�r�r�r�r�r�rrrrr!"s�
T
B
/'�
~

y

($/%



:
.


'




r!c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ImportErrorTestscCs�td�}|�|j�|�|j�tddd�}|�|jd�|�|j�tddd�}|�|jd�|�|j�tdddd�}|�|jd�|�|jd�d}|�t|��tdd	d
�Wd�n1s�0Y|�t|��tddd	d�Wd�n1�s0Y|�t|��tdd
d	d�Wd�n1�s@0Y|�t|��td	d
�Wd�n1�sx0Y|�t|��tdd	dd�Wd�n1�s�0YdS)N�testZ
somemodule��name�somepath��path�somename)r�r�z8'invalid' is an invalid keyword argument for ImportError�keyword)�invalidr�)r�r�r�)r�r�T)r�Zanother)r/r�r�r�r&r�rB)rr"rZrrr�test_attributes<s.*..*z ImportErrorTests.test_attributescCs�tdddd�}|�|jd�|�|jd�|�|jd�|�|jd�|��|�|jd�|�|jd�|�|jd�|�|jd�dS)Nr�r�r��r�r��r�r)r/r&r�rZr�r�rr�rrr�test_reset_attributes^sz&ImportErrorTests.test_reset_attributescCsTtdtfdd��0d}t|�}|�t|�t|��Wd�n1sF0YdS)NrJT)�quietsabc)r�BytesWarningr/r&r%)r�argr"rrr�test_non_str_argumentlsz&ImportErrorTests.test_non_str_argumentcCs�t�tdd�tdd�tddd�fD]�}td	i|��}ttjd�D]R}t�t�||��}|�|jd�|�|j	d�|�|j
|j
�|�|j|j�qBtjtj
fD]H}||�}|�|jd�|�|j	d�|�|j
|j
�|�|j|j�q�q"dS)
Nr�r�r�r�r�r�r8r�)r�)�dictr/rPr�r�rMr�r&r�rZr�r��copy�deepcopy)r�kwargsZorig�protor"r9rrr�test_copy_pickless$
�z!ImportErrorTests.test_copy_pickleN)rrrr�r�r�r�rrrrr�:s"r��__main__)r��gcr�rHr�r�rr�Ztest.supportrrrrrrrr	r
rrr�r
rrrrZTestCaser!r�rr�rrrr�<module>s84$M

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists