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_exceptions.cpython-310.pyc
o

�9j�k�@s\ddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZm
Z
mZmZmZmZddlmZddlmZmZddlmZddlmZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�ZGdd�dej�Z dZ!Gdd�dej�Z"Gdd�dej�Z#Gdd�dej�Z$Gdd�dej�Z%Gdd�dej�Z&e'dkr�e�(�dSdS)�N)�dedent)�captured_stderr�check_impl_detail�cpython_only�
gc_collect�
no_tracing�
script_helper�SuppressCrashReport)�
import_module)�TESTFN�unlink)�check_warnings)�supportc@�eZdZdd�ZdS)�NaiveExceptioncC�
||_dS�N��x��selfr�r�+/usr/lib/python3.10/test/test_exceptions.py�__init__�
zNaiveException.__init__N��__name__�
__module__�__qualname__rrrrrr�rc@�eZdZdZdd�ZdS)�SlottedNaiveExceptionrcCrrrrrrrrrzSlottedNaiveException.__init__N)rrr�	__slots__rrrrrr!�r!c@r)�BrokenStrExceptioncC�td��)Nzstr() is broken��	Exception�rrrr�__str__!�zBrokenStrException.__str__N)rrrr)rrrrr$ rr$c@sVeZdZdd�Zdd�Zdd�Zdd�Zd�dd�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/d0�Zd1d2�Zd3d4�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+dKdL�Z,dMdN�Z-dOdP�Z.dQdR�Z/e
�0dS�dTdU��Z1dVdW�Z2dXdY�Z3dZd[�Z4ed\d]��Z5e
d^d_��Z6e
d`da��Z7e
dbdc��Z8ddde�Z9e
dfdg��Z:e
dhdi��Z;e
djdk��Z<e
dldm��Z=edndo��Z>dpdq�Z?drds�Z@dtdu�ZAe
dvdw��ZBdxdy�ZCdzd{�ZDd|d}�ZEe
�d~d�d�d���ZFd�d��ZGd	S)��ExceptionTestscCs�|j||d��Lz|d��|y"}z
t|�}WYd}~nd}~wwz|d��|y=}z
t|�}WYd}~nd}~ww|�||�|�|j|�Wd�dS1sVwYdS)N)�exc�excname�spam)�subTest�str�assertEqualr)rr,r-�err�buf1�buf2rrr�raise_catch(s ����"�zExceptionTests.raise_catchc
Cs|�td�|�tttd�|�td�ttddd�}|��ttddd�}tj	}z"zddl
}|�d	�Wn	ty>YnwW|t_	|��tt�n|t_	|��tt�w|�t
d
�|�t
tdd�|�td�|�ttd
�|�td�g}|�t|jd�|�td�i}|�t|jd�|�td�|�td�|�td�zt}Wn	ty�Ynw|�td�d}td�D]}||7}q�|�td�|�td�|�td�ztd�Wn	ty�Ynw|�td�|�td�ztddd �Wn
t�yYnw|� d!�|�t!d"�|�t"d#�|�t"tj#d�|�t$d$�zgd%Wn
t$�y6Ynw|�t%d&�|�t%t&d'�|�t'd(�zdd}Wn
t'�yZYnw|�t(d)�zdd}Wnt(�yz}zWYd}~nd}~ww|�t)d*�dS)+N�AttributeError�undefined_attribute�EOFError�w�utf-8��encoding�rr��OSErrorzthis file does not exist�ImportError�undefined_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)*r5r6�assertRaises�getattr�sysr8�openr�close�stdin�marshal�loadsrr?r@�
__import__rB�__getitem__rDrFrGrH�undefined_variablerI�rangerLrMrNrQrOrP�compile�failrRrS�exitrTrU�chrrVr'rW)r�fp�	savestdinr^r�dummy�errr�testRaising5s���
�


�
�zExceptionTests.testRaisingcs(�fdd�}d}||d�|dd�dS)Ncs��j||d��@zt|dd�Wn!ty1}z|j|kr'��d||jf�WYd}~nd}~ww��d�Wd�dSWd�dS1sJwYdS)N)�src�msg�
<fragment>rQ�expected %s, got %s�"failed to get expected SyntaxError)r/rdrNrnre)rmrnrkr(rr�ckmsg�s
����"z4ExceptionTests.testSyntaxErrorMessage.<locals>.ckmsgzHif 1:
        try:
            continue
        except:
            passz'continue' not properly in loopz	continue
r�rrr�srr(r�testSyntaxErrorMessage�s

z%ExceptionTests.testSyntaxErrorMessagecs�tf�fdd�	}d}||d�d}||d�d}||d�d}||d�d	}||d�d
}||d�d}||d�d
}||dt�d}||dt�dS)Nc
srzt|dd�Wn)|y1}z|j|kr&��d||jf�WYd}~dSWYd}~dSd}~ww��d�dS)NrorQrprq)rdrnre)rmrn�	exceptionrkr(rrrr�s
"���z:ExceptionTests.testSyntaxErrorMissingParens.<locals>.ckmsgzprint "old style"z@Missing parentheses in call to 'print'. Did you mean print(...)?zprint "old style",zprint f(a+b,c)zexec "old style"z>Missing parentheses in call to 'exec'. Did you mean exec(...)?z
exec f(a+b,c)zprint (a+b,c) $ 42zinvalid syntaxzexec (a+b,c) $ 42zif True:
print "No indent"z9expected an indented block after 'if' statement on line 1z6if True:
        print()
	exec "mixed tabs and spaces"z2inconsistent use of tabs and spaces in indentation)rNrOrPrsrr(r�testSyntaxErrorMissingParens�s&	






z+ExceptionTests.testSyntaxErrorMissingParensNr:c		Cs|j|||d��v|�t��}t|dd�Wd�n1swY|�|jj|�|�|jj|�|dur@|�|jj|�|durL|�|jj	|�|jj
durvt|t�s]|�
|d�}|�d�|d}|�||jj
�Wd�dSWd�dS1s�wYdS)N)�source�lineno�offsetrorQ�replace�
rJ)r/rXrNrdr1rvryrz�
end_lineno�
end_offset�text�
isinstancer0�decode�split�assertIn)	rrmryrzr}r~r<�cm�linerrr�check�s$�
�
"�zExceptionTests.checkcCs|j}|ddd�dS)Nz"\
"(1 for c in I,\
\��r��rr�rrr�)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!dddd"�|d#dddd
�|d$dd%dd�|d&dd%dd�|d'dd�|d(dd�|d)dd�|d*dd�|d+dd�|d,dd%�|d-dd�|d.dd/�|d0dd �|d1dd%�|d2dd%�|d3dd%d4d�|d5dd6�|d7dd�|d8dd�|d9dd�|d:d;d<�|d=dd>�|d?dd>�|d@ddA�|dBdd �|dCdd>�|dDdd�|dEddF�|dGdd�|dHdd�|dIdd�|dJdd�|dKdd�|dLdd�|dMdd�|dNdd�|dOdd�|dPdd�|dQdd�|dRdd�|dSdd�|dTdd �dS)UNzdef fact(x):
	return x!
r�rCz1 +
rJ�z def spam():
  print(1)
 print(2)�zPython = "Python" +�uPython = "Ṕýţĥòñ" +s+# -*- coding: cp1251 -*-
Python = "ϳ���" +��cp1251r;sPython = "ϳ���" +�zx = "a�zlambda x: x = 2zf{a + b + c}zile for str(file) in []
]�ua = « hello » « world »z[
file
for str(file)
in
[]
]zile for
 str(file) in []]zages = {'Alice'=22, 'Bob'=23}�	z7match ...:
    case {**rest, "key": value}:
        ...z
[a b c d e f]zfor x yfff:�zf(a for a in b, c)�zf(a for a in b if a, c)zf(a, b for b in c)�zf(a, b for b in c, d)zclass foo:return 1zdef f():
  continuezdef f():
  breakz4try:
  pass
except:
  pass
except ValueError:
  passz(0x+1)zx = 0xIz0010 + 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+)z[interesting
foo()
s#coding: utf8
print('我')
r���z7f'''
            {
            (123_a)
            }'''�ztf'''
            {
            f"""
            {
            (123_a)
            }
            """
            }'''z4f"""


            {
            6
            0="""�
z!x = [(yield i) for i in range(3)]zdef f():
  from _ import *zdef f(x, x):
  passz3{i for i in range(5) if (j := 0) for j in range(5)}�&zdef 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)zfor 1 in []: passz
(yield i) = 2zdef f(*):
  passr�r�rrr�testSyntaxErrorOffset�s���	�
���z$ExceptionTests.testSyntaxErrorOffsetcsnGdd�dt��Gdd�d����fdd�}��fdd�}��fd	d
�}tj�d�s5|�|�|�dSdS)Nc@r)z9ExceptionTests.testSettingException.<locals>.BadExceptioncSr%)Nzcan't instantiate BadException)rL)�self_rrrrEr*zBExceptionTests.testSettingException.<locals>.BadException.__init__Nrrrrr�BadExceptionDrr�c@�eZdZdS)z=ExceptionTests.testSettingException.<locals>.InvalidExceptionN�rrrrrrr�InvalidExceptionH�r�c
s�ddl}z|��d�Wn.ty:}z"t��\}}}|jj}��|jd���	|j
�d��WYd}~dSd}~ww��d�dS)NrrJ�
test_capi1�test_exceptions.py�Expected exception)
�	_testcapi�raise_exceptionrTrZ�exc_info�tb_frame�f_coder1�co_name�
assertTrue�co_filename�endswithre)r�r2r,�tb�co�r�rrrr�Ks ��z7ExceptionTests.testSettingException.<locals>.test_capi1c
s�ddl}z|��d�Wn:tyF}z.t��\}}}|jj}��|jd���	|j
�d��|jjj}��|jd�WYd}~dSd}~ww��
d�dS)Nrrr��
test_capi2r�)r�r�rLrZr�r�r�r1r�r�r�r��f_backre)r�r2r,r�r��co2r�rrr�Ws
��z7ExceptionTests.testSettingException.<locals>.test_capi2csddl}��t|j�d�dS)NrrJ)r�rXrRr�)r�)r�rrr�
test_capi3es
�z7ExceptionTests.testSettingException.<locals>.test_capi3�java)r'rZ�platform�
startswith)rr�r�r�r)r�r�rr�testSettingException?s
�z#ExceptionTests.testSettingExceptioncCs�ztWn
tyYdSw|�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��1001�messagez[Errno 1001] messager��foo�barz[Errno 9] foo: 'bar'rr�r�z[WinError 3] foo: 'bar'�z[WinError 1001] foo)�WindowsErrorrH�assertIsr?r1r0�errno�winerror�strerror�filename�	filename2)rr9rrr�test_WindowsErrorosD��
z ExceptionTests.test_WindowsError�win32ztest specific to WindowscCsNtd�}d}|�td|��|j�|�Wd�dS1s wYdS)z:Should fill in unknown error code in Windows error message�ctypeslcs�@zWindows Error 0x%xN)r
�assertRaisesRegexr?�	pythonapi�PyErr_SetFromWindowsErr)rr��coderrr�test_windows_message�s
"�z#ExceptionTests.test_windows_messagecCstdddiftdddiftdddiftdddiftdddd�ftddddddd�ftd	d	dddd
d�ftdd	dddd
d�ftd
d	ddd�ftdddddd�ftddddddd�ftddddddddd�ftdddddddddd�ftddd ddddd!d"d#d$�	ftd%dd%dddddddd&�	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/d0d1d*dd2�ft	dddd3�ft
dddd3�fg}z|�tdddddddd4�f�Wn	t
y�Ynw|D]�\}}}z||�}Wntd5||ftjd6�Yq�t|�j�d7��s$|�t|�jd8�t|�}|D]}t||�}|�t|�t||�d9|||||f��q*tfD]7}	t|	jd�D],}
|	�||
�}|	�|�}|D]}tt||��}t||�}
|�||
d:||f��qc�qT�qKq�dS);Nr�args)rJ)r�)r�rJr�)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�)rJr�r�)rJr�rJ)r�r�r�r�r�)rnrr�ryrzr~�print_file_and_line)�msgStrr�)r�rr�rnr�ryrzr~)r�)r��	linenoStr�	offsetStr�textStr�endLinenoStr�endOffsetStrr�r�r�r�r�)	rzrr�r�rnr�ryr}r~)r�r�r�r�r�r�r��print_file_and_lineStr)	rr�r�rnr�ryrzr}r~)�ascii�arrJ�ordinal not in ranger�r�rr�)r�r<�object�start�reason��)r�r�rrJr�)�あrrJ�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)�
BaseExceptionrSr?rN�UnicodeError�UnicodeEncodeError�UnicodeDecodeError�	bytearray�UnicodeTranslateErrorrr!�appendr�rH�printrZ�stderr�typerr�r1rr0rY�repr�picklerc�HIGHEST_PROTOCOL�dumpsr_)r�
exceptionListr,r��expectedrkrt�checkArgName�value�p�protocol�new�got�wantrrr�testAttributes�s0���������
����������	��
�������������U����


��

������zExceptionTests.testAttributescCs�ztd��t��d}Yt��|�}|�|t�|�|j|�td��|�}|�|t�|�|j|�Gdd�dt�}|��|�}|�||�|�|j|�dS)Nr�r�r�c@r�)z5ExceptionTests.testWithTraceback.<locals>.MyExceptionNr�rrrr�MyException2r�r)	rBrZr�r��with_traceback�assertIsInstancer1�
__traceback__r')rr�rkrrrr�testWithTraceback$sz ExceptionTests.testWithTracebackc
CsRzdt�_Wnty!}z|�dt|��WYd}~dSd}~ww|�d�dS)Nr�z!__traceback__ must be a traceback�No exception raised)r'rrTr�r0re�rrkrrr�testInvalidTraceback9s��z#ExceptionTests.testInvalidTracebackcCsP|�ttt�dd�|�ttt�d�|�ttt�dd�|�ttt�d�dS)N�	__cause__rJ�__context__)rXrT�setattrr'�delattrr(rrr�testInvalidAttrsAszExceptionTests.testInvalidAttrscCsBztd��t��d}Yt�}||_d|_|�|jd�dS)Nr�r�)rBrZr�r'rr1)rr�rkrrr�testNoneClearsTracebackAttrGsz*ExceptionTests.testNoneClearsTracebackAttrcCsnt�}|�|j�|�|j�t�}|�|j�|�|j�Gdd�dt�}|�}|�|j�|�|j�dS)Nc@r�)z5ExceptionTests.testChainingAttrs.<locals>.MyExceptionNr�rrrrr[r�r)r'�assertIsNoner
r	rTr?)rrkrrrr�testChainingAttrsRsz ExceptionTests.testChainingAttrsc
Cs�zt��ty}z|}WYd}~nd}~ww|�|j�|�|j�|�|j�t�|_d|_|�|jt�|�|j�|�|j�d|_|�|j�dS)NF)	r'rr
r	�assertFalse�__suppress_context__rHrr�)rr,rkrrr�testChainingDescriptorsbs ��z&ExceptionTests.testChainingDescriptorscCs<|jttdd�Gdd�dt�}|dd�}|�|jd�dS)NrJ)r�c@r)z8ExceptionTests.testKeywordArgs.<locals>.DerivedExceptioncSst�|�||_dSr)r�r�	fancy_arg)rrrrrrzs

zAExceptionTests.testKeywordArgs.<locals>.DerivedException.__init__Nrrrrr�DerivedExceptionyrr�*)r)rXrTr�r1r)rrrrrr�testKeywordArgsts
zExceptionTests.testKeywordArgscs4�fdd��|�t���fdd��|�t��dS)Ncs��Srrr)�frrr��z/ExceptionTests.testInfiniteRecursion.<locals>.fcsz��WStyYdSw)Nr��rUr��grrr�s
�z/ExceptionTests.testInfiniteRecursion.<locals>.g)rXrMr(r)rrr�testInfiniteRecursion�sz$ExceptionTests.testInfiniteRecursioncCs8|�tt��|�ttd���|�ttdd���dS)Nr��b)r�r0r'r(rrr�test_str�szExceptionTests.test_strc
Cszzt��ty}z|�|t�WYd}~nd}~ww|�dt��|�t��|Wd�dS1s6wYdS�Nrk�r'r�assertNotIn�localsrX�UnboundLocalErrorrrrr�test_exception_cleanup_names�s��"�z+ExceptionTests.test_exception_cleanup_namesc
Cs|zt��ty}z
|�|t�~WYd}~nd}~ww|�dt��|�t��|Wd�dS1s7wYdSr r!rrrr�test_exception_cleanup_names2�s��"�z,ExceptionTests.test_exception_cleanup_names2cs�Gdd�dt��Gdd�d�}��fdd�}|��t���}z|�Wn�y5}zWYd}~nd}~wwd�t�|��|���|��t���}z|�Wn	�yYYnwd�t�|��|���|��t���}z|�WnYd�t�|��|���|��t���}dD]}z|�Wq�Yd�t�|��|���|��t���}z
z|�Wnt�Wn*ty�}zd|_d�t�|��tdd	�r�t�|���WYd}~nd}~ww|��t���}z|�Wn��yzz����yYnwYnwd�tdd	��rt�|��|���Gd
d�d�}|��t���}|��|�Wd�n	1�sDwYd�tdd	��rTt�|��|���dS)Nc@r)z=ExceptionTests.testExceptionCleanupState.<locals>.MyExceptioncSrr��obj�rr(rrrr�rzFExceptionTests.testExceptionCleanupState.<locals>.MyException.__init__Nrrrrrr�rrc@r�)z7ExceptionTests.testExceptionCleanupState.<locals>.MyObjNr�rrrr�MyObj�r�r*cs�}����rr)�	local_ref�rr(rr�inner_raising_func�szDExceptionTests.testExceptionCleanupState.<locals>.inner_raising_func)rF)�cpythonc@�eZdZdd�Zdd�ZdS)z9ExceptionTests.testExceptionCleanupState.<locals>.ContextcS�|Srrr(rrr�	__enter__�zCExceptionTests.testExceptionCleanupState.<locals>.Context.__enter__cSsdS)NTr)r�exc_type�	exc_value�exc_tbrrr�__exit__r2zBExceptionTests.testExceptionCleanupState.<locals>.Context.__exit__N�rrrr1r6rrrr�Context�r8)r'�weakref�refrrrDr
r)rr*r-�wrrk�ir8rr,r�testExceptionCleanupState�s�

��


�








�
��

��

�z(ExceptionTests.testExceptionCleanupStatec
sD�fdd�}ztWdSty!�z
|�WYd��dSd��ww)Ncs�dSrrr�rkrr�print_error&r*zIExceptionTests.test_exception_target_in_nested_scope.<locals>.print_error)�	somethingr')rr@rr?r�%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�ztd��ty{|�}|�t|�t�|�t��dt�|�t|�t�|�t��dt�|�t|�t�~|�t��dt�YdSw)NcssL�ztd��tyt��dVt��dVYnwt��dVdS)N�caughtr)rDrZr�rrrr�yield_raise1s��z:ExceptionTests.test_generator_leaking.<locals>.yield_raiserr�)r1�nextrDrZr�rT)rrDrrrr�test_generator_leaking.s&�z%ExceptionTests.test_generator_leakingcCsbdd�}zt�ty|�}t|�Ynwzt|�Wn	ty&Ynw|�t��d�dS)Ncss�dVdSrrrrrrrN��
z1ExceptionTests.test_generator_leaking2.<locals>.g�NNN)rLrE�
StopIterationr1rZr��rr�itrrr�test_generator_leaking2Ls��z&ExceptionTests.test_generator_leaking2c
Cs�dd�}|�}t|�zddWn1tyB}z%|�t��d|�|�|�}|�t��d|�|�||�WYd}~nd}~ww|�t��d�dS)Ncss2�zdVWdStyt��dVYdSw�NrJ�rVrZr�rrrrr^s��z1ExceptionTests.test_generator_leaking3.<locals>.grJrrH)rErVr�rZr��throwr1)rrrKrk�gen_excrrr�test_generator_leaking3[s
��z&ExceptionTests.test_generator_leaking3c
Cs�dd�}|�}zt�tyt|�}Ynw|�|t�zt|�Wnty?}z|�t��d|�WYd}~nd}~ww|�t��d�dS)Ncss0�zddWdStyt��dV�w�NrJrrNrrrrrqs��z1ExceptionTests.test_generator_leaking4.<locals>.grJrH)rTrEr�rVrZr�r1)rrrK�tprkrrr�test_generator_leaking4ns� ��z&ExceptionTests.test_generator_leaking4csD�fdd�}|�}zt�tyt|�Ynw��tt|�dS)Nc3s0���t��dt�dV��t��d�dS)NrJrH)rrZr�rLr1rr(rrr�s�z>ExceptionTests.test_generator_doesnt_retain_old_exc.<locals>.g)rLrErXrIrJrr(r�$test_generator_doesnt_retain_old_exc�s�z3ExceptionTests.test_generator_doesnt_retain_old_exccs4dd���fdd�}|�t�|�t��d�dS)Ncss�dVdSrMrrrrr�
simple_gen�rGzIExceptionTests.test_generator_finalizing_and_exc_info.<locals>.simple_gencs&��}zt�tyt|�YSwr)rLrE)�gen�rVrr�run_gen�s�zFExceptionTests.test_generator_finalizing_and_exc_info.<locals>.run_genrH)rr1rZr�)rrYrrXr�&test_generator_finalizing_and_exc_info�s
z5ExceptionTests.test_generator_finalizing_and_exc_infocstGdd�dt��Gdd�d�}��fdd�}|��t���}|�}t|�||�d}�t�|��|���dS)Nc@r)zFExceptionTests._check_generator_cleanup_exc_state.<locals>.MyExceptioncSrrr'r)rrrr�rzOExceptionTests._check_generator_cleanup_exc_state.<locals>.MyException.__init__Nrrrrrr�rrc@r�)z@ExceptionTests._check_generator_cleanup_exc_state.<locals>.MyObjNr�rrrrr*�r�r*c3s&�z�����ydVYdSwrrrr,rr�raising_gen�s��zFExceptionTests._check_generator_cleanup_exc_state.<locals>.raising_gen)r'r:r;rErr)r�testfuncr*r[r<rrr,r�"_check_generator_cleanup_exc_state�s
z1ExceptionTests._check_generator_cleanup_exc_statecC�dd�}|�|�dS)NcSs(z	|�t��WdStyYdSwr)rOrLrrrr�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_statecCr^)NcSs|��dSr)r\rrrr�do_close��zGExceptionTests.test_generator_close_cleanup_exc_state.<locals>.do_closer`)rrbrrr�&test_generator_close_cleanup_exc_state��z5ExceptionTests.test_generator_close_cleanup_exc_statecCr^)NcSsd}dSrrrrrr�do_del�r*zCExceptionTests.test_generator_del_cleanup_exc_state.<locals>.do_delr`)rrfrrr�$test_generator_del_cleanup_exc_state�rez3ExceptionTests.test_generator_del_cleanup_exc_statec��fdd�}��|�dS)Ncs0zt|�Wn
tyYdSw��d�dS�Nz should have raised StopIteration)rErIrerr(rr�do_next�s�zEExceptionTests.test_generator_next_cleanup_exc_state.<locals>.do_nextr`)rrjrr(r�%test_generator_next_cleanup_exc_state��z4ExceptionTests.test_generator_next_cleanup_exc_statecrh)Ncs2z|�d�Wn
tyYdSw��d�dSri)�sendrIrerr(rr�do_send�s�zEExceptionTests.test_generator_send_cleanup_exc_state.<locals>.do_sendr`)rrnrr(r�%test_generator_send_cleanup_exc_state�rlz4ExceptionTests.test_generator_send_cleanup_exc_statecs@G�fdd�d�}d�zt|���Yt�|��d�dS)Nc�eZdZ�fdd�ZdS)z*ExceptionTests.test_3114.<locals>.MyObjectcst���dSr)rZr�r(r?rr�__del__�sz2ExceptionTests.test_3114.<locals>.MyObject.__del__N�rrrrqrr?rr�MyObject��rsrrH)r'rr1)rrsrr?r�	test_3114�s
zExceptionTests.test_3114cCsHGdd�dt�}Gdd�dt�}Gdd�dt�}z[z|�|ys}zL|}z|�|yn}z;|}z|�|yi}z*|}	|�||�|�||�|�|	|�|�|j�|�|j|�|�|	j|�|�d}~wwd}~wwd}~ww|y�}
z|
}WYd}
~
nd}
~
ww|�||�|�|j|	�|�|	j|�|�|j�dS)Nc@r�)zHExceptionTests.test_raise_does_not_create_context_chain_cycle.<locals>.ANr�rrrr�A�r�rvc@r�)zHExceptionTests.test_raise_does_not_create_context_chain_cycle.<locals>.BNr�rrrr�B�r�rwc@r�)zHExceptionTests.test_raise_does_not_create_context_chain_cycle.<locals>.CNr�rrrr�C�r�rx)r'rrr
r�)rrvrwrx�a_r��b_r�c_�crkr,rrr�.test_raise_does_not_create_context_chain_cycle�sJ��������z=ExceptionTests.test_raise_does_not_create_context_chain_cyclec
Csldd�}z|�Wnty}z|}WYd}~nd}~ww|�|t�|�|jt�|�|jj|j�dS)Nc
Ss0ztd��ty}z||_td��d}~ww)NrJr�)rUr
rT��exrrr�cycles��zBExceptionTests.test_no_hang_on_context_chain_cycle1.<locals>.cycle)r'rrTr
rUr�)rr�rkr,rrr�$test_no_hang_on_context_chain_cycle1s
��z3ExceptionTests.test_no_hang_on_context_chain_cycle1zSee issue 44895cCs�Gdd�dt�}Gdd�dt�}Gdd�dt�}|�|��<}z|��|yX}z+|}z|��|yS}z|}z|��|yN}	z|	}
|
|_|
�d}	~	wwd}~wwd}~ww1s\wY|�|j|
�|�|
j|�|�|j|�|�|j|
�dS)Nc@r�)z>ExceptionTests.test_no_hang_on_context_chain_cycle2.<locals>.ANr�rrrrrv0r�rvc@r�)z>ExceptionTests.test_no_hang_on_context_chain_cycle2.<locals>.BNr�rrrrrw2r�rwc@r�)z>ExceptionTests.test_no_hang_on_context_chain_cycle2.<locals>.CNr�rrrrrx4r�rx�r'rXr
r�rv)rrvrwrxr��_ar��_br�_cr|rrr�$test_no_hang_on_context_chain_cycle2,s:�������z3ExceptionTests.test_no_hang_on_context_chain_cycle2cCsdGdd�dt�}Gdd�dt�}Gdd�dt�}Gdd�dt�}Gd	d
�d
t�}|�|��Q}z|��|y}}z@|}z|��|yx}	z.|	}
z|��|ys}z|}||_z|��|yn}
z|
}|�}|�d}
~
wwd}~wwd}	~	wwd}~ww1s�wY|�|j|�|�|j|�|�|j|�|�|j|
�|�|
j|�|�|j|�dS)Nc@r�)z>ExceptionTests.test_no_hang_on_context_chain_cycle3.<locals>.ANr�rrrrrvTr�rvc@r�)z>ExceptionTests.test_no_hang_on_context_chain_cycle3.<locals>.BNr�rrrrrwVr�rwc@r�)z>ExceptionTests.test_no_hang_on_context_chain_cycle3.<locals>.CNr�rrrrrxXr�rxc@r�)z>ExceptionTests.test_no_hang_on_context_chain_cycle3.<locals>.DNr�rrrr�DZr�r�c@r�)z>ExceptionTests.test_no_hang_on_context_chain_cycle3.<locals>.ENr�rrrr�E\r�r�r�)rrvrwrxr�r�r�r�r�r�rr�r|�_d�drkrrr�$test_no_hang_on_context_chain_cycle3QsP���������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��xxxxxrJr�r�z8'baz' codec can't encode characters in position 1-4: foor�z<'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: 965230951443685724997�xxxxz/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�r1r0r�r�r<r�r�r�)r�urrr�test_unicode_change_attributes�s>z-ExceptionTests.test_unicode_change_attributescCs.tttf}|D]
}|�t|�|��d�qdS)N�)r�r�r�r1r0�__new__)r�klasses�klassrrr�test_unicode_errors_no_object�s
�z,ExceptionTests.test_unicode_errors_no_objectcs�Gdd�dt�}Gdd�dt|d�}t��3}zt��|y0}z|�d�WYd}~nd}~wty8Yn	|�d�YWd�n1sKwY�fdd	����\}}}|�|tt|��|�d
t|��dS)Nc@r)z/ExceptionTests.test_badisinstance.<locals>.MetacS�t��rr)�cls�subclassrrr�__subclasscheck__�rzAExceptionTests.test_badisinstance.<locals>.Meta.__subclasscheck__N)rrrr�rrrr�Meta�rr�c@r�)z6ExceptionTests.test_badisinstance.<locals>.MyExceptionNr�rrrrr�r�r)�	metaclassz%exception should not be a MyExceptionzShould have raised KeyErrorcs$z��WStyt��YSwr)rMrZr�rrrrr�s
�z,ExceptionTests.test_badisinstance.<locals>.gz maximum recursion depth exceeded)	r�r'rrDrerrMr�r0)rr�rr�rk�vr�rrr�test_badisinstance�s$���z!ExceptionTests.test_badisinstancecCsdd�}|�t��dS)NcSst�}td�D]}|j}qdS)Ni@B)r�rc�__dir__)�orrrrr��s�z3ExceptionTests.test_trashcan_recursion.<locals>.foo)rr)rr�rrr�test_trashcan_recursion�sz&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.')
        �-Wd�-crJsRecursionErrorsResourceWarning�Done.)�__file__r�assert_python_failurer1r��rr��rc�outr2rrr�$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.')
        r�rJsORecursionError: maximum recursion depth exceeded while normalizing an exceptionr�)rr�r1r�r�rrr�-test_recursion_normalizing_infinite_exceptions�z<ExceptionTests.test_recursion_normalizing_infinite_exceptionc
s�dd�}�fdd���fdd���fdd��t��}z>|d	����fD],}|j|d
��z|�Wn	ty;Ynw|�d�Wd�n1sKwYq$Wt�|�dSt�|�w)NcSsFd}	zt�|�Wn
ty|d7}Ynwnqt�||�dSrM)rZ�setrecursionlimitrM)�n�depthrrr�set_relative_recursion_limit)s��zUExceptionTests.test_recursion_in_except_handler.<locals>.set_relative_recursion_limitcs"zddWdS��YdSrRrr)�recurse_in_exceptrrr�4szJExceptionTests.test_recursion_in_except_handler.<locals>.recurse_in_exceptcs zddWnY��dSrRrr)�recurse_after_exceptrrr�:s

zMExceptionTests.test_recursion_in_except_handler.<locals>.recurse_after_exceptcs z��WdS��YdSrrr)�recurse_in_body_and_exceptrrr�AszSExceptionTests.test_recursion_in_except_handler.<locals>.recurse_in_body_and_exceptrC)�funcz#Should have raised a RecursionError)rZ�getrecursionlimitr/rMrer�)rr��recursionlimitr�r)r�r�r�r� test_recursion_in_except_handler's(
�
����	z/ExceptionTests.test_recursion_in_except_handlercCsNd}t��t�d|�\}}}|�d|�Wd�dS1s wYdS)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)
        r�smFatal Python error: _PyErr_NormalizeException: Cannot recover from MemoryErrors while normalizing exceptions.)r	rr�r�r�rrr�)test_recursion_normalizing_with_no_memoryVs�"�z8ExceptionTests.test_recursion_normalizing_with_no_memorycs@ddl�ddlm����fdd�}|�}|�}��||�dS)Nr��raise_memoryerrorc
sJz��Wnty}z	|j}WYd}~n
d}~ww��d���|�S)Nz Should have raised a MemoryError)rGrre�	format_tb)rkr��r�r�	tracebackrr�
raiseMemErrorts
��

z6ExceptionTests.test_MemoryError.<locals>.raiseMemError)r�r�r�r1)rr��tb1�tb2rr�r�test_MemoryErrorns	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@r�)z1ExceptionTests.test_exception_with_doc.<locals>.CNr�rrrrrx�r�rxz_testcapi.error4z_testcapi.error5r�r�rJ)r�rXrR�make_exception_with_docr�r�r��
issubclassr'r�__doc__r1r�r�)
rr��doc2�doc4r��error2�error3rx�error4�error5rrr�test_exception_with_doc�s:
�
���z&ExceptionTests.test_exception_with_docc
s�ddlm�Gdd�d��d����fdd�}z|�Wnty5}z
|���d�WYd}~n
d}~ww|�d�t�|���d�dS)Nrr�c@r�)z3ExceptionTests.test_memory_error_cleanup.<locals>.CNr�rrrrrx�r�rxc���}t�|����dSr�r:r;�r|�rxr�r<rr�inner��

z7ExceptionTests.test_memory_error_cleanup.<locals>.innerzMemoryError not raised)r�r�rG�assertNotEqualrerr1)rr�rkrr�r�test_memory_error_cleanup�s
��
z(ExceptionTests.test_memory_error_cleanupc
s�Gdd�d��d����fdd��z��Wnty/}z
|���d�WYd}~n
d}~ww|�d�t�|���d�dS)Nc@r�)z6ExceptionTests.test_recursion_error_cleanup.<locals>.CNr�rrrrrx�r�rxcr�rr�r��rxr�r<rrr��r�z:ExceptionTests.test_recursion_error_cleanup.<locals>.innerzRecursionError not raised)rMr�rerr1rrr�r�test_recursion_error_cleanup�s
��
z+ExceptionTests.test_recursion_error_cleanupcCsN|�t��
}t�t�Wd�n1swY|�|jjtj|j�dSr)	rXr?�os�listdirr�r1rvr��ENOTDIR)rr�rrr�test_errno_ENOTDIR�s�z!ExceptionTests.test_errno_ENOTDIRcCsjGdd�d�}|�}t���}~t�|�|jj|j�|�|jj�Wd�dS1s.wYdS)Nc@r)z1ExceptionTests.test_unraisable.<locals>.BrokenDelcSstd�}|�)Nz
del is brokenr�rr,rrrrq�sz9ExceptionTests.test_unraisable.<locals>.BrokenDel.__del__Nrrrrrr�	BrokenDel�rr�)	r�catch_unraisable_exceptionrr1�
unraisabler�rq�assertIsNotNone�
exc_traceback)rr�r(r�rrr�test_unraisable�s
"�zExceptionTests.test_unraisablec
Cs�ttfD]q}|�|��bz|d�}|�|y5t��}tjt���Wd�n1s.wYYnw|��}|�d|�|�d|�|�|j	|�|turX|�d|�n|�d|�|�
|�d��Wd�n1spwYqdS)Nztest messager�z	raise excz<exception str() failed>r|)rUr$r/rrZ�__excepthook__r��getvaluer�rr�r�)rr3r,r��reportrrr�test_unhandled�s,������zExceptionTests.test_unhandledcCsFd}tdd�D]}t�d||�\}}}|�|d�|�d|�qdS)Nz�if 1:
            import _testcapi
            class C(): pass
            _testcapi.set_nomemory(0, %d)
            C()
        rJr�r�)rJ�xsMemoryError)rcrr�r�)rr�r=r�r�r2rrr�"test_memory_error_in_PyErr_PrintExs
�z1ExceptionTests.test_memory_error_in_PyErr_PrintExcszGdd�dt��Gdd�dt����fdd�}|�}|�d�|����|����Wd�dS1s6wYdS)Nc@r�)zBExceptionTests.test_yield_in_nested_try_excepts.<locals>.MainErrorNr�rrrr�	MainErrorr�r�c@r�)zAExceptionTests.test_yield_in_nested_try_excepts.<locals>.SubErrorNr�rrrr�SubErrorr�r�c3s6�z����yzdVW��yY�wwrrr�r�r�rr�mains����z=ExceptionTests.test_yield_in_nested_try_excepts.<locals>.main)r'rmrXrO)rr��cororr�r� test_yield_in_nested_try_exceptss

"�z/ExceptionTests.test_yield_in_nested_try_exceptscsN�fdd�}|�}zt�ty��t|�d�Ynw��t|�d�dS)Nc3s:�zt�tydVYnw��t��d�dVdS)NrJrHr�)rUr1rZr�rr(rrr*s�
�
z?ExceptionTests.test_generator_doesnt_retain_old_exc2.<locals>.grJr�)rBr1rE)rrrWrr(r�%test_generator_doesnt_retain_old_exc2(s�z4ExceptionTests.test_generator_doesnt_retain_old_exc2cCstdd�}|�t��'|�}zddWnt|�t|�YWd�dSWd�dS1s3wYdS)Ncss
�dV�rMrrrrrr<s�z1ExceptionTests.test_raise_in_generator.<locals>.grJr)rXrVrE)rrr=rrr�test_raise_in_generator:s�"�z&ExceptionTests.test_raise_in_generatorTz Won't work if __debug__ is Falsec
CsRtazJd��ty(}zb|�|t�|�t|�d�WYd}~dSd}~ww)NF�hello)rT�AssertionErrorr�rr1r0rerrrr�test_assert_shadowingIs��z$ExceptionTests.test_assert_shadowingcCs�Gdd�dt�}zt�ty}z|}WYd}~nd}~wwz|�ty*Ynwtd�D]}zt�tyE}zWYd}~nd}~wwt�q/dS)Nc@r�)zBExceptionTests.test_memory_error_subclasses.<locals>.TestExceptionNr�rrrr�
TestExceptionbr�r�rC)rGr'rcr)rr�r,�inst�_rrr�test_memory_error_subclassesYs*	������z+ExceptionTests.test_memory_error_subclasses)NNr:)Hrrrr5rlrurwr�r�r�rr�r��unittest�
skipUnlessrZr�r�rrrr
rrrrrrrr%r&r>rBrFrLrQrTrUrZr]rardrgrkrorur}r��skipr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr+&s�
T
)a
/'�

y

(
$/%


:
/


'




r+c@�deZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�NameErrorTestsc
Cs@ztWdSty}z|�d|j�WYd}~dSd}~ww)N�bluch)r�rHr1�namer�rrr�test_name_error_has_namezs
��z'NameErrorTests.test_name_error_has_namecCs�dd�}dd�}dd�}dd�}d	d
�}dd�}|d
f|df|df|df|df|dffD]A\}}d}	z|�Wn-tyd}
z!t���}	tjt���Wd�n1sUwYWYd}
~
nd}
~
ww|�||	���q,dS)NcS� d}}}}d}tt�dSr�r�r�)�noise�
more_noiser��bc�blechrrr�Substitution��z@NameErrorTests.test_name_error_suggestions.<locals>.SubstitutioncSr�rr�)r�rr�r�blchrrr�Elimination�rz?NameErrorTests.test_name_error_suggestions.<locals>.EliminationcSr�rr�)r�rr�r�bluchinrrr�Addition�rz<NameErrorTests.test_name_error_suggestions.<locals>.AdditioncS�d}d}tt�dSrr�)�blach�blucrrr�SubstitutionOverElimination��zONameErrorTests.test_name_error_suggestions.<locals>.SubstitutionOverEliminationcSr	rr�)r
�bluchirrr�SubstitutionOverAddition�r
zLNameErrorTests.test_name_error_suggestions.<locals>.SubstitutionOverAdditioncSr	rr�)�blucharrrr�EliminationOverAddition�r
zKNameErrorTests.test_name_error_suggestions.<locals>.EliminationOverAddition�'blech'?�'blch'?�
'bluchin'?z	'blucha'?�'blach'?�rHrrrZr�r�r�r�)rrrrrrrr��
suggestionr2r,rrr�test_name_error_suggestions�s0�

����z*NameErrorTests.test_name_error_suggestionscC�dd�}z|�Wn-ty6}z!t���}tjt���Wd�n1s'wYWYd}~nd}~ww|�d|���dS)NcS�tt�dSr)r��global_for_suggestiorrrrr��rczENameErrorTests.test_name_error_suggestions_from_globals.<locals>.funcz'global_for_suggestions'?r�rr�r,r2rrr�(test_name_error_suggestions_from_globals��

���z7NameErrorTests.test_name_error_suggestions_from_globalscCr)NcSrr)r��ZeroDivisionErrrrrrrrrr��rczFNameErrorTests.test_name_error_suggestions_from_builtins.<locals>.funcz'ZeroDivisionError'?rrrrr�)test_name_error_suggestions_from_builtins�rz8NameErrorTests.test_name_error_suggestions_from_builtinscCr)NcSsd}tt�dSr)r��somethingverywronghe)�somethingverywrongheheheheheherrrr�szSNameErrorTests.test_name_error_suggestions_do_not_trigger_for_long_names.<locals>.f�somethingverywronghehe�rHrrrZr�r�r"r��rrr,r2rrr�9test_name_error_suggestions_do_not_trigger_for_long_names�s

���zHNameErrorTests.test_name_error_suggestions_do_not_trigger_for_long_namescCs�d}}}}}|jdd��jztWn-tyB}z!t���}tjt���Wd�n1s3wYWYd}~nd}~ww|�d|�	��|�d|�	��|�d|�	��|�d|�	��|�d|�	��|�d|�	��Wd�n1s}wY|jd	d��jzt
Wn-ty�}z!t���}tjt���Wd�n1s�wYWYd}~nd}~ww|�d|�	��|�d|�	��|�d|�	��|�d|�	��|�d|�	��|�d|�	��Wd�n1s�wY|jd
d��lztWn/t�y4}z"t���}tjt���Wd�n	1�s%wYWYd}~nd}~ww|�d|�	��|�d|�	��|�d|�	��|�d|�	��|�d|�	��|�d|�	��Wd�n	1�spwY|jdd��mztWn/t�y�}z"t���}tjt���Wd�n	1�s�wYWYd}~nd}~ww|�d|�	��|�d|�	��|�d|�	��|�d|�	��|�d|�	��|�d|�	��Wd�dS1�s�wYdS)Nr�r��you mean�vvv�mom�'id'�'w'�'pytho'r��m�py)
r/rrHrrrZr�r�r"r�r�r.r/)rr)r*r9�id�pythor,r2rrr�>test_name_error_bad_suggestions_do_not_trigger_for_small_names�s�
����

����

����

���$�zMNameErrorTests.test_name_error_bad_suggestions_do_not_trigger_for_small_namescCs�dd�}z|�Wn-ty6}z!t���}tjt���Wd�n1s'wYWYd}~nd}~ww|�|��d�dS)Nc Ss�d}}}}}}}}}}	}
}}}
}}}}}}}}}}}}}}}}}}} }!}"}#}$}%}&}'}(})}*}+},}-}.}/}0}1}2}3}4}5}6}7}8}9}:};}<}=}>}?}@}A}B}C}D}E}F}G}H}I}J}K}L}M}N}O}P}Q}R}S}T}U}V}W}X}Y}Z}[}\}]}^}_}`}a}b}c}d}e}f}g}h}i}j}k}l}m}n}o}p}q}r}s}t}u}v}w}x}y}z}{}|}}}~}}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}��}�}�}�}�}�}�}�}�}�}	�}
�}�}�}
�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�} �}!�}"�}#�}$�}%�}&�}'�}(�})�}*�}+�},�}-�}.�}/�}0�}1�}2�}3�}4�}5�}6�}7�}8�}9�}:�};�}<�}=�}>�}?�}@�}A�}B�}C�}D�}E�}F�}G�}H�}I�}J�}K�}L�}M�}N�}O�}P�}Q�}R�}S�}T�}U�}V�}W�}X�}Y�}Z�}[�}\�}]�}^�}_�}`�}a�}b�}c�}d�}e�}f�}g�}h�}i�}j�}k�}l�}m�}n�}o�}p�}q�}r�}s�}t�}u�}v�}w�}x�}y�}z�}{�}|�}}�}~�}�}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}�}�}�}�}�}�}�}�}�}	�}
�}�}�}
�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�} �}!�}"�}#�}$�}%�}&�}'�}(�})�}*�}+�},�}-�}.�}/�}0�}1�}2�}3�}4�}5�}6�}7�}8�}9�}:�};�}<�}=�}>�}?�}@�}A�}B�}C�}D�}E�}F�}G�}H�}I�}J�}K�}L�}M�}N�}O�}P�}Q�}R�}S�}T�}U�}V�}W�}X�}Y�}Z�}[�}\�}]�}^�}_�}`�}a�}b�}c�}d�}e�}f�}g�}h�}i�}j�}k�}l�}m�}n�}o�}p�}q�}r�}s�}t�}u�}v�}w�}x�}y�}z�}{�}|�}}�}~�}�}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}��}�}�}�}�}�}�}�}�}�}	�}
�}�}�}
�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}�}tt�dSr)r��a0( �a1�a2�a3�a4�a5�a6�a7�a8�a9�a10�a11�a12�a13�a14�a15�a16�a17�a18�a19�a20�a21�a22�a23�a24�a25�a26�a27�a28�a29�a30�a31�a32�a33�a34�a35�a36�a37�a38�a39�a40�a41�a42�a43�a44�a45�a46�a47�a48�a49�a50�a51�a52�a53�a54�a55�a56�a57�a58�a59�a60�a61�a62�a63�a64�a65�a66�a67�a68�a69�a70�a71�a72�a73�a74�a75�a76�a77�a78�a79�a80�a81�a82�a83�a84�a85�a86�a87�a88�a89�a90�a91�a92�a93�a94�a95�a96�a97�a98�a99�a100�a101�a102�a103�a104�a105�a106�a107�a108�a109�a110�a111�a112�a113�a114�a115�a116�a117�a118�a119�a120�a121�a122�a123�a124�a125�a126�a127�a128�a129�a130�a131�a132�a133�a134�a135�a136�a137�a138�a139�a140�a141�a142�a143�a144�a145�a146�a147�a148�a149�a150�a151�a152�a153�a154�a155�a156�a157�a158�a159�a160�a161�a162�a163�a164�a165�a166�a167�a168�a169�a170�a171�a172�a173�a174�a175�a176�a177�a178�a179�a180�a181�a182�a183�a184�a185�a186�a187�a188�a189�a190�a191�a192�a193�a194�a195�a196�a197�a198�a199�a200�a201�a202�a203�a204�a205�a206�a207�a208�a209�a210�a211�a212�a213�a214�a215�a216�a217�a218�a219�a220�a221�a222�a223�a224�a225�a226�a227�a228�a229�a230�a231�a232�a233�a234�a235�a236�a237�a238�a239�a240�a241�a242�a243�a244�a245�a246�a247�a248�a249�a250�a251�a252�a253�a254�a255�a256�a257�a258�a259�a260�a261�a262�a263�a264�a265�a266�a267�a268�a269�a270�a271�a272�a273�a274�a275�a276�a277�a278�a279�a280�a281�a282�a283�a284�a285�a286�a287�a288�a289�a290�a291�a292�a293�a294�a295�a296�a297�a298�a299�a300�a301�a302�a303�a304�a305�a306�a307�a308�a309�a310�a311�a312�a313�a314�a315�a316�a317�a318�a319�a320�a321�a322�a323�a324�a325�a326�a327�a328�a329�a330�a331�a332�a333�a334�a335�a336�a337�a338�a339�a340�a341�a342�a343�a344�a345�a346�a347�a348�a349�a350�a351�a352�a353�a354�a355�a356�a357�a358�a359�a360�a361�a362�a363�a364�a365�a366�a367�a368�a369�a370�a371�a372�a373�a374�a375�a376�a377�a378�a379�a380�a381�a382�a383�a384�a385�a386�a387�a388�a389�a390�a391�a392�a393�a394�a395�a396�a397�a398�a399�a400�a401�a402�a403�a404�a405�a406�a407�a408�a409�a410�a411�a412�a413�a414�a415�a416�a417�a418�a419�a420�a421�a422�a423�a424�a425�a426�a427�a428�a429�a430�a431�a432�a433�a434�a435�a436�a437�a438�a439�a440�a441�a442�a443�a444�a445�a446�a447�a448�a449�a450�a451�a452�a453�a454�a455�a456�a457�a458�a459�a460�a461�a462�a463�a464�a465�a466�a467�a468�a469�a470�a471�a472�a473�a474�a475�a476�a477�a478�a479�a480�a481�a482�a483�a484�a485�a486�a487�a488�a489�a490�a491�a492�a493�a494�a495�a496�a497�a498�a499�a500�a501�a502�a503�a504�a505�a506�a507�a508�a509�a510�a511�a512�a513�a514�a515�a516�a517�a518�a519�a520�a521�a522�a523�a524�a525�a526�a527�a528�a529�a530�a531�a532�a533�a534�a535�a536�a537�a538�a539�a540�a541�a542�a543�a544�a545�a546�a547�a548�a549�a550�a551�a552�a553�a554�a555�a556�a557�a558�a559�a560�a561�a562�a563�a564�a565�a566�a567�a568�a569�a570�a571�a572�a573�a574�a575�a576�a577�a578�a579�a580�a581�a582�a583�a584�a585�a586�a587�a588�a589�a590�a591�a592�a593�a594�a595�a596�a597�a598�a599�a600�a601�a602�a603�a604�a605�a606�a607�a608�a609�a610�a611�a612�a613�a614�a615�a616�a617�a618�a619�a620�a621�a622�a623�a624�a625�a626�a627�a628�a629�a630�a631�a632�a633�a634�a635�a636�a637�a638�a639�a640�a641�a642�a643�a644�a645�a646�a647�a648�a649�a650�a651�a652�a653�a654�a655�a656�a657�a658�a659�a660�a661�a662�a663�a664�a665�a666�a667�a668�a669�a670�a671�a672�a673�a674�a675�a676�a677�a678�a679�a680�a681�a682�a683�a684�a685�a686�a687�a688�a689�a690�a691�a692�a693�a694�a695�a696�a697�a698�a699�a700�a701�a702�a703�a704�a705�a706�a707�a708�a709�a710�a711�a712�a713�a714�a715�a716�a717�a718�a719�a720�a721�a722�a723�a724�a725�a726�a727�a728�a729�a730�a731�a732�a733�a734�a735�a736�a737�a738�a739�a740�a741�a742�a743�a744�a745�a746�a747�a748�a749�a750�a751�a752�a753�a754�a755�a756�a757�a758�a759�a760�a761�a762�a763�a764�a765�a766�a767�a768�a769�a770�a771�a772�a773�a774�a775�a776�a777�a778�a779�a780�a781�a782�a783�a784�a785�a786�a787�a788�a789�a790�a791�a792�a793�a794�a795�a796�a797�a798�a799�a800rrrrsXR*���������������������������������������������������������������������������������	�	�	�	�	�	�	�	�	�	�
�
�
�
�
�
�
�
�
�
���������������������
�
�
�
�
�
�
�
�
�
������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� � � � � � � � � � �!�!�!�!�!�!�!�!�!�!�"�"�"�"�"�"�"�"�"�"�#�#�#�#�#�#�#�#�#�#�$�$�$�$�$�$�$�$�$�$�%�%�%�%�%�%�%�%�%�%�&�&�&�&�&�&�&�&�&�&�'�'�'�'�'�'�'�'�'�'�(�(�(�(�(�(�(�(�(�(�)�)�)�)�)�)�)�)�)�)�*�*�*�*�*�*�*�*�*�*�+�+�+�+�+�+�+�+�+�+�,�,�,�,�,�,�,�,�,�,�-�-�-�-�-�-�-�-�-�-�.�.�.�.�.�.�.�.�.�.�/�/�/�/�/�/�/�/�/�/�0�0�0�0�0�0�0�0�0�0�1�1�1�1�1�1�1�1�1�1�2�2�2�2�2�2�2�2�2�2�3�3�3�3�3�3�3�3�3�3�4�4�4�4�4�4�4�4�4�4�5�5�5�5�5�5�5�5�5�5�6�6�6�6�6�6�6�6�6�6�7�7�7�7�7�7�7�7�7�7�8�8�8�8�8�8�8�8�8�8�9�9�9�9�9�9�9�9�9�9�:�:�:�:�:�:�:�:�:�:�;�;�;�;�;�;�;�;�;�;�<�<�<�<�<�<�<�<�<�<�=�=�=�=�=�=�=�=�=�=�>�>�>�>�>�>�>�>�>�>�?�?�?�?�?�?�?�?�?�?�@�@�@�@�@�@�@�@�@�@�A�A�A�A�A�A�A�A�A�A�B�B�B�B�B�B�B�B�B�B�C�C�C�C�C�C�C�C�C�C�D�D�D�D�D�D�D�D�D�D�E�E�E�E�E�E�E�E�E�E�F�F�F�F�F�F�F�F�F�F�G�G�G�G�G�G�G�G�G�G�H�H�H�H�H�H�H�H�H�H�I�I�I�I�I�I�I�I�I�I�J�J�J�J�J�J�J�J�J�J�K�K�K�K�K�K�K�K�K�K�L�L�L�L�L�L�L�L�L�L�M�M�M�M�M�M�M�M�M�M�N�N�N�N�N�N�N�N�N�N�O�O�O�O�O�O�O�O�OzXNameErrorTests.test_name_error_suggestions_do_not_trigger_for_too_many_locals.<locals>.fz
NameError.*a1)rHrrrZr�r��assertNotRegexr�r%rrr�>test_name_error_suggestions_do_not_trigger_for_too_many_localssU

���zMNameErrorTests.test_name_error_suggestions_do_not_trigger_for_too_many_localscCsdd�}z|�Wn-ty6}z!t���}tjt���Wd�n1s'wYWYd}~nd}~ww|�d|���dd�}z|�Wn-tyu}z!t���}tjt���Wd�n1sfwYWYd}~nd}~ww|�d|���dS)NcSs
d}t��r�rH�rrrrrdsz@NameErrorTests.test_name_error_with_custom_exceptions.<locals>.frcSsd}t�rrVrWrrrrpsr$r%rrr�&test_name_error_with_custom_exceptionscs(

���

���z5NameErrorTests.test_name_error_with_custom_exceptionscCr)NcSsd}t|�d}dS)Nr�)r�)rA�	somethongrrrr�}szDNameErrorTests.test_unbound_local_error_doesn_not_match.<locals>.foorA)r$rrrZr�r�r"r�)rr�r,r2rrr�(test_unbound_local_error_doesn_not_match|s

���z7NameErrorTests.test_unbound_local_error_doesn_not_matchcsv�fdd�}z|�Wn%�jy0t���}tjt���Wd�n1s)wYYnw��d|���dS)Ncs6��td��tWd�dS1swYdS)N�aaa)r�rH�aabrr(rrr�s"�z)NameErrorTests.test_issue45826.<locals>.fr\)�failureExceptionrrrZr�r�r�r��rrr2rr(r�test_issue45826�s

���zNameErrorTests.test_issue45826cCs�dd�}z|�Wn$ty-t���}tjt���Wd�n1s&wYYnw|�d|���|�d|���dS)Nc
Ss4ztWdSty}z|�d�t��d}~wwr)�nonsenser�rrV)r�rrrr�s

��z1NameErrorTests.test_issue45826_focused.<locals>.fr`rV)rVrrrZr�r�r�r�r^rrr�test_issue45826_focused�s

���z&NameErrorTests.test_issue45826_focusedN)rrrr�rrr r&r2rUrXrZr_rarrrrr�ys-


7^r�c@steZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�AttributeErrorTestscCsTtd�}|�|j�|�|j�t�}tdd|d�}|�|jd�|�|j|�dS)NzOuch!�Ouch�carry�r�r()r6rr�r(r�r1r�)rr,�sentinelrrr�test_attributes�sz#AttributeErrorTests.test_attributesc
Cs�Gdd�d�}|�}z|jWn ty/}z|�d|j�|�||j�WYd}~nd}~wwz	t�|d�WdStyZ}z|�d|j�|�||j�WYd}~dSd}~ww)Nc@�eZdZdZdS)z<AttributeErrorTests.test_getattr_has_name_and_obj.<locals>.AN�rrrrrrrrrv��rvr�)r�r6r1r�r(r��__getattribute__�rrvr(r,rrr�test_getattr_has_name_and_obj�s 
����z1AttributeErrorTests.test_getattr_has_name_and_objc
CsfGdd�d�}|�}z|��WdSty2}z|�d|j�|�||j�WYd}~dSd}~ww)Nc@r)zGAttributeErrorTests.test_getattr_has_name_and_obj_for_method.<locals>.AcS�dSrrr(rrrr�r2zMAttributeErrorTests.test_getattr_has_name_and_obj_for_method.<locals>.A.blechNrirrrrrv�rrvr�)r�r6r1r�r(rlrrr�(test_getattr_has_name_and_obj_for_method�s��z<AttributeErrorTests.test_getattr_has_name_and_obj_for_methodcCsGdd�d�}Gdd�d�}Gdd�d�}Gdd�d�}Gd	d
�d
�}Gdd�d�}|d
f|df|df|df|df|dffD]@\}}z|�jWn-tyu}	z!t���}
tjt���Wd�n1sfwYWYd}	~	nd}	~	ww|�||
���q>dS)Nc@� eZdZdZZZZdZdS)zBAttributeErrorTests.test_getattr_suggestions.<locals>.SubstitutionN)rrrr�rr�rrrrrrr��rc@rp)zAAttributeErrorTests.test_getattr_suggestions.<locals>.EliminationN)rrrr�rr�rrrrrrr�rqrc@rp)z>AttributeErrorTests.test_getattr_suggestions.<locals>.AdditionN)rrrr�rr�rrrrrrr�rqrc@�eZdZdZdZdS)zQAttributeErrorTests.test_getattr_suggestions.<locals>.SubstitutionOverEliminationN)rrrr
rrrrrr��rc@rr)zNAttributeErrorTests.test_getattr_suggestions.<locals>.SubstitutionOverAdditionN)rrrr
rrrrrr�rsrc@rr)zMAttributeErrorTests.test_getattr_suggestions.<locals>.EliminationOverAdditionN)rrrrrrrrrr�rsrrrrz'bluc'?r�	r�r6rrrZr�r�r�r�)rrrrrrrr�rr,r2rrr�test_getattr_suggestions�s.�
����z,AttributeErrorTests.test_getattr_suggestionscC�Gdd�d�}z|�jWn-ty:}z!t���}tjt���Wd�n1s+wYWYd}~nd}~ww|�d|���dS)Nc@rh)zZAttributeErrorTests.test_getattr_suggestions_do_not_trigger_for_long_attributes.<locals>.ANrirrrrrv�rjrvr)	�somethingverywrongr6rrrZr�r�r"r��rrvr,r2rrr�;test_getattr_suggestions_do_not_trigger_for_long_attributes��
���zOAttributeErrorTests.test_getattr_suggestions_do_not_trigger_for_long_attributescCs�Gdd�d�}|jdd��kz|jWn-ty@}z!t���}tjt���Wd�n1s1wYWYd}~nd}~ww|�d|�	��|�d|�	��|�d|�	��|�d|�	��|�d	|�	��|�d
|�	��Wd�n1s{wY|jdd��kz|j
Wn-ty�}z!t���}tjt���Wd�n1s�wYWYd}~nd}~ww|�d|�	��|�d|�	��|�d|�	��|�d|�	��|�d	|�	��|�d
|�	��Wd�n1s�wY|jdd��mz|jWn/t�y4}z"t���}tjt���Wd�n	1�s%wYWYd}~nd}~ww|�d|�	��|�d|�	��|�d|�	��|�d|�	��|�d	|�	��|�d
|�	��Wd�n	1�spwY|jd
d��nz|jWn/t�y�}z"t���}tjt���Wd�n	1�s�wYWYd}~nd}~ww|�d|�	��|�d|�	��|�d|�	��|�d|�	��|�d	|�	��|�d
|�	��Wd�dS1�s�wYdS)Nc@s eZdZdZZZZZdS)zfAttributeErrorTests.test_getattr_error_bad_suggestions_do_not_trigger_for_small_names.<locals>.MyClassN)rrrr)r*r9r0r1rrrr�MyClasssr{rr'r(r)r*r+r,r-r�r.r/)
r/rr6rrrZr�r�r"r�r�r.r/)rr{r,r2rrr�Atest_getattr_error_bad_suggestions_do_not_trigger_for_small_namess�

����


����


����


���$�zUAttributeErrorTests.test_getattr_error_bad_suggestions_do_not_trigger_for_small_namescCs�Gdd�d�}td�D]}t|d|��d�qz|�jWn-tyJ}z!t���}tjt���Wd�n1s;wYWYd}~nd}~ww|�	d|�
��dS)Nc@rh)zTAttributeErrorTests.test_getattr_suggestions_do_not_trigger_for_big_dicts.<locals>.ANrirrrrrv?rjrvi��index_r)rcrr�r6rrrZr�r�r"r�)rrv�indexr,r2rrr�5test_getattr_suggestions_do_not_trigger_for_big_dicts>s
���zIAttributeErrorTests.test_getattr_suggestions_do_not_trigger_for_big_dictscCsGdd�d�}z|�jWn-ty:}z!t���}tjt���Wd�n1s+wYWYd}~nd}~ww|�d|���Gdd�d�}z|�jWn-ty}}z!t���}tjt���Wd�n1snwYWYd}~nd}~ww|�d|���dS)Nc@�eZdZdZdd�ZdS)�?AttributeErrorTests.test_getattr_suggestions_no_args.<locals>.ANcSr�r�r6�r�attrrrr�__getattr__Qr�KAttributeErrorTests.test_getattr_suggestions_no_args.<locals>.A.__getattr__�rrrrr�rrrrrvOr#rvrc@r�)r�NcS�t�rr�r�rrrr�^r2r�r�rrrrrv\r#rtrxrrr� test_getattr_suggestions_no_argsNs(
���
���z4AttributeErrorTests.test_getattr_suggestions_no_argscs�Gdd�d��G�fdd�d�}Gdd�d�}Gdd�d�}|||fD]>}z|�jWn-tyX}z!t���}tjt���Wd�n1sIwYWYd}~nd}~ww|�d	|���q#dS)
Nc@rr)zTAttributeErrorTests.test_getattr_suggestions_invalid_args.<locals>.NonStringifyClassN)rrrr)�__repr__rrrr�NonStringifyClassjrsr�cseZdZdZ�fdd�ZdS)zDAttributeErrorTests.test_getattr_suggestions_invalid_args.<locals>.ANcs
t����rr�r��r�rrr�przPAttributeErrorTests.test_getattr_suggestions_invalid_args.<locals>.A.__getattr__r�rr�rrrvnsrvc@r�)zDAttributeErrorTests.test_getattr_suggestions_invalid_args.<locals>.BNcSs
tdd��)N�Error�r�r�rrrr�urzPAttributeErrorTests.test_getattr_suggestions_invalid_args.<locals>.B.__getattr__r�rrrrrwsr#rwc@r�)zDAttributeErrorTests.test_getattr_suggestions_invalid_args.<locals>.CNcSr%)Nr�r�r�rrrr�zr*zPAttributeErrorTests.test_getattr_suggestions_invalid_args.<locals>.C.__getattr__r�rrrrrxxr#rxrrt)rrvrwrxr�r,r2rr�r�%test_getattr_suggestions_invalid_argsis
����z9AttributeErrorTests.test_getattr_suggestions_invalid_argscCrv)Nc@r)zEAttributeErrorTests.test_getattr_suggestions_for_same_name.<locals>.AcSsdgS)Nrrr(rrrr��rzMAttributeErrorTests.test_getattr_suggestions_for_same_name.<locals>.A.__dir__N)rrrr�rrrrrv�rrv�Did you mean)	rr6rrrZr�r�r"r�rxrrr�&test_getattr_suggestions_for_same_name�rzz:AttributeErrorTests.test_getattr_suggestions_for_same_namecCs�Gdd�d�}z|�jWn-ty:}z!t���}tjt���Wd�n1s+wYWYd}~nd}~ww|�d|���|�d|���dS)Nc@r )zEAttributeErrorTests.test_attribute_error_with_failing_dict.<locals>.TrJcSr%)N�oh no!r�r(rrrr��r*zMAttributeErrorTests.test_attribute_error_with_failing_dict.<locals>.T.__dir__N)rrrr�r�rrrr�T�r#r�rr�)	�blichr6rrrZr�r�r"r�)rr�r,r2rrr�&test_attribute_error_with_failing_dict�s
���z:AttributeErrorTests.test_attribute_error_with_failing_dictcCs|ztddd��ty3}z!t���}tjt���Wd�n1s$wYWYd}~nd}~ww|�d|���dS)N�r�re�?)r6rrrZr�r�r"r�)rr,r2rrr�"test_attribute_error_with_bad_name�s
���z6AttributeErrorTests.test_attribute_error_with_bad_namecs�Gdd�d��G�fdd�d�}z|�jWn-tyC}z!t���}tjt���Wd�n1s4wYWYd}~nd}~ww|�d|���|�d|���dS)Nc@seZdZdZdS)zIAttributeErrorTests.test_attribute_error_inside_nested_getattr.<locals>.ArJN)rrrr�rrrrrv�rjrvcrp)zIAttributeErrorTests.test_attribute_error_inside_nested_getattr.<locals>.Bcs��}|jSr)r�)rr�r��rvrrrk�szZAttributeErrorTests.test_attribute_error_inside_nested_getattr.<locals>.B.__getattribute__N)rrrrkrr�rrrw�rtrwr�r�)	rAr6rrrZr�r�r�r�)rrwr,r2rr�r�*test_attribute_error_inside_nested_getattr�s
���z>AttributeErrorTests.test_attribute_error_inside_nested_getattrN)rrrrgrmroruryr|rr�r�r�r�r�r�rrrrrb�s'9	rbc@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�n1sdwY|�t|��tddd	d�Wd�n1s�wY|�t|��tdd
d	d�Wd�n1s�wY|�t|��
td	d
�Wd�n1s�wY|�t|��tdd	dd�Wd�dS1s�wYdS)N�test�
somemoduler'�somepath��path�somename)r�r�z8'invalid' is an invalid keyword argument for ImportError�keyword)�invalidr�)r�r�r�)r�r�T)r��another)r@rr�r�r1r�rT)rr,rnrrrrg�s8����"�z ImportErrorTests.test_attributescCs�tdddd�}|�|jd�|�|jd�|�|jd�|�|jd�|��|�|jd�|�|jd�|�|jd�|�|jd�dS)Nr�r�r��r�r��r�r)r@r1r�rnr�r�rr�rrr�test_reset_attributes�sz&ImportErrorTests.test_reset_attributescCsVtdtfdd��d}t|�}|�t|�t|��Wd�dS1s$wYdS)Nr�T)�quietsabc)r
�BytesWarningr@r1r0)r�argr,rrr�test_non_str_argument�s
"�z&ImportErrorTests.test_non_str_argumentcCs�t�tdd�tdd�tddd�fD]e}tdi|��}ttjd�D])}t�t�||��}|�|jd�|�|j	d�|�|j
|j
�|�|j|j�q!tjtj
fD]$}||�}|�|jd�|�|j	d�|�|j
|j
�|�|j|j�qQqdS)	Nr�r'r�r�r�r�rJr�)�dictr@rcr�r�r_r�r1r�rnr�r��copy�deepcopy)r�kwargs�orig�protor,r|rrr�test_copy_pickle�s(
���z!ImportErrorTests.test_copy_pickleN)rrrrgr�r�r�rrrrr��s
"r�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�SyntaxErrorTestsc
Csdtd�fdtd�fdtd�fdtd�fdtd	�fd
td	�fdtd	�fdtd	�fd
td�fg	}|D]W\}}|j|d��Eztd|��tyx}z+t���}tjt���Wd�n1s_wY|�||�	��|}WYd}~nd}~wwWd�n1s�wYq1dS)N)�bad.pyrJr��abcdefgrJr�z�
               File "bad.py", line 1
                 abcdefg
                  ^^^^^
             SyntaxError: bad bad
             )r�rJr�r�rJr�z�
               File "bad.py", line 1
                 abcdefg
                  ^
             SyntaxError: bad bad
             )r�rJr�r�rJ���)r�rJr�r�rJr�z�
               File "bad.py", line 1
                 abcdefg
                    ^
             SyntaxError: bad bad
             )r�rJ���r�rJr�zn
               File "bad.py", line 1
                 abcdefg
             SyntaxError: bad bad
             )r�rJr�r�rJ���)r�rJrr�rJr)r�rJrr�rJr��r�rJr�r�rJ�dz�
               File "bad.py", line 1
                 abcdefg
                  ^^^^^^
             SyntaxError: bad bad
             )r��bad bad)
rr/rNrrrZr�r�r�r�)r�casesr�r�r,r2�
the_exceptionrrr�test_range_of_offsets
	s|��	��	��	��	�����������O

������z&SyntaxErrorTests.test_range_of_offsetscCs2d}zDttddd��
}|�|�Wd�n1swYt�dddt�\}}}|�d���}|�|d	d
�|�|dd�Wtt�ntt�wd
}zEttddd��
}|�|�Wd�n1sfwYt�dddt�\}}}|�d���}|�|d	d�|�|dd�Wtt�dStt�w)NuU# -*- coding: cp437 -*-
"¢¢¢¢¢¢" + f(4, x for x in range(1))
r9�cp437r;r��-X�utf8r:���u@    "┬ó┬ó┬ó┬ó┬ó┬ó" + f(4, x for x in range(1))r�z-                          ^^^^^^^^^^^^^^^^^^^z# -*- coding: ascii -*-

(
r�z    (z    ^)	r[r�writerr�r��
splitlinesr1r)rrx�testfiler�r�r2rrr�test_encodingsd	s*���zSyntaxErrorTests.test_encodingscCs�z;ttd��
}|�d�Wd�n1swYt�dddt�\}}}|�d���}|�d|d�Wtt�dStt�w)	N�bw��r�r�r�r:z8SyntaxError: Non-UTF-8 code starting with '\x89' in filer�)	r[rr�rr�r�r�r�r)rr�r�r�r2rrr�
test_non_utf8�	s�zSyntaxErrorTests.test_non_utf8c	Cs�d}td|�}|\}}}}}}|�||j�|�||j�|�||j�|�||j�|�||j�|�||j�|�d|j�dS)Nr�r��	rNr1r�ryr}rzr~rrn)	rr�r�r�ryrz�errorr}r~rrr�test_attributes_new_constructor�	s
z0SyntaxErrorTests.test_attributes_new_constructorcCs�d}td|�}|\}}}}|�||j�|�||j�|�d|j�|�||j�|�d|j�|�||j�|�d|j�dS)N)r�rJr�r�r�r�)rr�r�r�ryrzr�rrr�test_attributes_old_constructor�	s
z0SyntaxErrorTests.test_attributes_old_constructorcCs@d}|�ttd|�d}|�ttd|�d}|�ttd|�dS)N)r�rJr�r�)r�rJr�r�r�r�r�)r�rJr�r�rJ)rXrTrN�rr�rrr�test_incorrect_constructor�	sz+SyntaxErrorTests.test_incorrect_constructorN)	rrrr�r�r�r�r�r�rrrrr�		sZr�c@r�)�PEP626Testsc
Gs�z|�Wnty}z	|j}WYd}~n
d}~ww|�d�g}|j}|r@|j}|�|jdur3dn|j|jj�|j}|s'|�	t
|�|�dS)Nr)r'rre�tb_nextr�r��f_linenor��co_firstlinenor1�tuple)rrr�r�t�lines�framerrr�lineno_after_raise�	s$
��
��zPEP626Tests.lineno_after_raisecC�dd�}|�|d�dS)NcS�dddSrRrrrrr�simple�	sz:PEP626Tests.test_lineno_after_raise_simple.<locals>.simplerJ�r�)rr�rrr�test_lineno_after_raise_simple�	sz*PEP626Tests.test_lineno_after_raise_simplecCr�)NcSs$zddWdSddYdSrRrrrrr�	in_except�	s
z@PEP626Tests.test_lineno_after_raise_in_except.<locals>.in_exceptr�r�)rr�rrr�!test_lineno_after_raise_in_except�	�z-PEP626Tests.test_lineno_after_raise_in_exceptcCr�)Nc
Ss6zddWdSty}zWYd}~dSd}~wwrR)rTr~rrr�other_except�	s��z@PEP626Tests.test_lineno_after_other_except.<locals>.other_exceptr�r�)rr�rrr�test_lineno_after_other_except�	�z*PEP626Tests.test_lineno_after_other_exceptcCr�)Nc
Ss>zddWdSty}zddWYd}~dSd}~wwrRr&r~rrr�in_named_except�	s��z@PEP626Tests.test_lineno_in_named_except.<locals>.in_named_exceptr�r�)rr�rrr�test_lineno_in_named_except�	r�z'PEP626Tests.test_lineno_in_named_exceptcCr�)NcSszddWdSwrRrrrrr�in_try�	s
z.PEP626Tests.test_lineno_in_try.<locals>.in_tryr�r�)rr�rrr�test_lineno_in_try�	r�zPEP626Tests.test_lineno_in_trycCr�)NcSszWdddSddwrRrrrrr�in_finally_normal�	s�zDPEP626Tests.test_lineno_in_finally_normal.<locals>.in_finally_normalr�r�)rr�rrr�test_lineno_in_finally_normal�	r�z)PEP626Tests.test_lineno_in_finally_normalcCr�)NcSs"zddWdddSddwrRrrrrr�in_finally_except�	s
�zDPEP626Tests.test_lineno_in_finally_except.<locals>.in_finally_exceptr�r�)rr�rrr�test_lineno_in_finally_except�	r�z)PEP626Tests.test_lineno_in_finally_exceptcs*Gdd�d���fdd�}|�|d�dS)Nc@r/)z0PEP626Tests.test_lineno_after_with.<locals>.NoopcSr0rrr(rrrr1
r2z:PEP626Tests.test_lineno_after_with.<locals>.Noop.__enter__cWrnrrr�rrrr6
r2z9PEP626Tests.test_lineno_after_with.<locals>.Noop.__exit__Nr7rrrr�Noop�	r9r�c�4���
ddWd�dS1swYdSrRrr�r�rr�
after_with
s"�z6PEP626Tests.test_lineno_after_with.<locals>.after_withr�r��rr�rr�r�test_lineno_after_with�	sz"PEP626Tests.test_lineno_after_withcCs4dd�}|�|d�|jjdd�|_|�|d�dS)NcSr�rRrrrrrr
rcz8PEP626Tests.test_missing_lineno_shows_as_none.<locals>.frJs���)�co_linetable)r��__code__r{)rrrrr�!test_missing_lineno_shows_as_none

sz-PEP626Tests.test_missing_lineno_shows_as_nonecs,Gdd�d���fdd�}|�|dd�dS)Nc@r/)zCPEP626Tests.test_lineno_after_raise_in_with_exit.<locals>.ExitFailscSr0rrr(rrrr1
r2zMPEP626Tests.test_lineno_after_raise_in_with_exit.<locals>.ExitFails.__enter__cWr�rrr�rrrr6
r2zLPEP626Tests.test_lineno_after_raise_in_with_exit.<locals>.ExitFails.__exit__Nr7rrrr�	ExitFails
r9r�cr�rRrr�r�rrr�
s
"�zDPEP626Tests.test_lineno_after_raise_in_with_exit.<locals>.after_withrJr�r�rr�r�$test_lineno_after_raise_in_with_exit
sz0PEP626Tests.test_lineno_after_raise_in_with_exitN)rrrr�r�r�r�r�r�r�r�r�r�r�rrrrr��	s				r��__main__))r��gcr�rZr�r�r:r��textwrapr�test.supportrrrrrrr	�test.support.import_helperr
�test.support.os_helperrr�test.support.warnings_helperr
r�rr'rr!r$�TestCaser+�global_for_suggestionsr�rbr�r�r�rr�rrrr�<module>sX$]3L(m�

Youez - 2016 - github.com/yon3zu
LinuXploit