HEX
Server: Apache
System: Linux bd12.noc223.com 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: handcraf (1693)
PHP: 8.1.28
Disabled: NONE
Upload Files
File: //opt/alt/python312/lib64/python3.12/test/__pycache__/test_exceptions.cpython-312.opt-2.pyc
�

�h�e�1��^�ddlZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZmZm
Z
mZmZmZddlmZddlmZmZddlmZddlmZ	ddlmZGd
�de�ZGd�d
e�ZGd�de�Z Gd�dejB�Z"Gd�dejB�Z#Gd�dejB�Z$Gd�dejB�Z%Gd�dejB�Z&Gd�dejB�Z'Gd�dejB�Z(e)dk(rejT�yy#e$rd	ZY��wxYw)�N)�dedent)�captured_stderr�check_impl_detail�cpython_only�
gc_collect�
no_tracing�
script_helper�SuppressCrashReport)�
import_module)�TESTFN�unlink)�check_warnings)�support)�INT_MAXi���c��eZdZd�Zy)�NaiveExceptionc��||_y�N��x��selfrs  �;/opt/alt/python312/lib64/python3.12/test/test_exceptions.py�__init__zNaiveException.__init__�	�����N��__name__�
__module__�__qualname__r�rrrrs��rrc��eZdZdZd�Zy)�SlottedNaiveExceptionrc��||_yrrrs  rrzSlottedNaiveException.__init__"rrN)rrr �	__slots__rr!rrr#r# s���I�rr#c��eZdZd�Zy)�BrokenStrExceptionc��td��)Nzstr() is broken��	Exception�rs r�__str__zBrokenStrException.__str__&s���)�*�*rN)rrr r,r!rrr'r'%s��+rr'c�l�eZdZd�Zd�Zd�Zd�ZdQd�Zd�Zd�Z	e
jee
jk\d	�ej d
�ej"edd�
�d����Zed��Zd�Ze
j,e
j.dk(d�d��Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$e%d ��Z&d!�Z'd"�Z(d#�Z)d$�Z*d%�Z+d&�Z,d'�Z-d(�Z.d)�Z/d*�Z0d+�Z1d,�Z2d-�Z3d.�Z4d/�Z5d0�Z6d1�Z7d2�Z8d3�Z9d4�Z:d5�Z;d6�Z<d7�Z=d8�Z>d9�Z?d:�Z@d;�ZAe%d<��ZBeej d
�d=���ZCed>��ZDed?��ZEd@�ZFedA��ZGedB��ZHedC��ZIedD��ZJe%dE��ZKdF�ZLdG�ZMdH�ZNedI��ZOdJ�ZPdK�ZQdL�ZRe
j,ddM�dN��ZSdO�ZTdP�ZUy)R�ExceptionTestsc�H�|j||��5	|d��#|$r}t|�}Yd}~nd}~wwxYw	|d��#|$r}t|�}Yd}~nd}~wwxYw|j||�|j|j|�ddd�y#1swYyxYw)N)�exc�excname�spam)�subTest�str�assertEqualr)rr0r1�err�buf1�buf2s      r�raise_catchzExceptionTests.raise_catch-s���
�\�\�c�7�\�
3�
	4�
 ��&�k�!���
 ��3�x���
 ��
 ��&�k�!���
 ��3�x���
 �����T�4�(����S�\�\�7�3�
	4�
	4�
	4�sH�B��8�3�B�8�B�A�A�	A�B�A�1B�B!c��|jtd�|jtttd�|jt
d�t
tdd��}|j�t
tdd��}tj}		ddl
}|jd	�|t_	|j�tt�|jtd
�|jttdd�|jtd�|jttd
�|jt d�g}|jt |j"d�|jt$d�i}|jt$|j"d�|jt&d�|jt(d�|jt*d�t,}|jt.d�d}t1d�D]}||z
}�	|jt2d�|jt4d�|jt6d�t9d�|jt:d�|jt<d�t?ddd �|jAd!�|jtBd"�|jtDd#�|jtDtjFd�|jtHd$�gd%z|jtJd&�|jtJtLd'�|jtNd(�ddz}|jtPd)�ddz}|jtRd*�y#t
$rY��wxYw#|t_	|j�tt�wxYw#t*$rY���wxYw#t6$rY���wxYw#t<$rY��UwxYw#tH$rY��wxYw#tN$rY��wxYw#tP$r
}Yd}~��d}~wwxYw)+N�AttributeError�undefined_attribute�EOFError�w�utf-8��encoding�rrr�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)*r9r;�assertRaises�getattr�sysr=�openr�close�stdin�marshal�loadsr
rCrD�
__import__rF�__getitem__rHrJrKrL�undefined_variablerM�rangerPrQrRrUrSrT�compile�failrVrW�exitrXrY�chrrZr*r[)r�fp�	savestdinrbr�dummy�es       r�testRaisingzExceptionTests.testRaising:s\������)9�:����.�'�3�8M�N�����:�.�
�&�#��
0��
���
�
�&�#��
0���I�I�	�		�
���
�
�c�"�"�C�I��H�H�J��6�N�����)�,����'�4�)C�S�I�����m�4����+�z�3E�F�����\�2������*�a�m�m�R�8�����:�.������(�A�M�M�5�9����*�,?�@�����m�4�����K�0�#�Q�	
�����8�
���3�Z�	�E�
��F�A�	�	
����~�6�����)9�:�����m�4�
�%�[�	
���)�+=�>�����:�.�
�@���)��i�i�-�.�����m�4�����\�2����*�c�h�h��2�����K�0�
�"�W�	
����\�2����*�c�6�2����*�,?�@��1��Q�	
����K�0��1��Q�	
���+�-A�B��K�
��
��"�C�I��H�H�J��6�N��,��$���� �D� ���������$���!�&�$�&���#�t��#�s��N�)O�O,�
O<�P�&P�P*�	N*�&N-�)N*�*N-�-,O�	O)�(O)�,	O9�8O9�<	P	�P	�	P�P�	P'�&P'�*	P=�8P=c�J���fd�}d}||d�|dd�|dd�y)Nc� ���j||��5	t|dd��jd�ddd�y#t$r:}|j|k7r!�jd|�d|j���Yd}~�Gd}~wwxYw#1swYyxYw)N)�src�msg�
<fragment>rU�"failed to get expected SyntaxError�	expected �, got )r3rhrirRrt)rsrtrors   �r�ckmsgz4ExceptionTests.testSyntaxErrorMessage.<locals>.ckmsg�s�������#�3��/�
D�D��C��v�6�
�I�I�B�C�
D�
D��#�H��u�u��|��	�	�3����"F�G���H��
D�
D�s1�B�
>�B�	B�0A<�7B�<B�B�B
zHif 1:
        try:
            continue
        except:
            passz'continue' not properly in loopz	continue
zf'{6 0}'z+invalid syntax. Perhaps you forgot a comma?r!�rry�ss`  r�testSyntaxErrorMessagez%ExceptionTests.testSyntaxErrorMessage�s3���	D�
��	�a�2�3�
�l�=�>�
�j�G�Hrc���tf�fd�	}d}||d�d}||d�d}||d�d}||d�d}||d�d	}||d
�d}||d
�d}||d
t�d}||dt�y)Nc����	t|dd��jd�y#|$r?}|j|k7r&�jd|�d|j���Yd}~yYd}~yd}~wwxYw)NrurUrvrwrx)rhrirt)rsrt�	exceptionrors    �rryz:ExceptionTests.testSyntaxErrorMissingParens.<locals>.ckmsg�s`���
@���\�6�2�
�	�	�>�?��	�
D��5�5�C�<��I�I�s�A�E�E�B�C�C� ��
D�s�
"�A&�0A!�!A&zprint "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)rRrSrTrzs`  r�testSyntaxErrorMissingParensz+ExceptionTests.testSyntaxErrorMissingParens�s����&1�	@�
$��
�a�S�T�$��
�a�S�T���
�a�S�T�"��
�a�Q�R���
�a�Q�R�

!��
�a�!�"���
�a�!�"�
.��
�a�L�N^�_�K��
�a�E�x�PrNc���|j|||��5|jt�5}t|dd�ddd�|j	j
j|�|j	|j
j|�|�&|j	|j
j|�|�&|j	|j
j|�|j
j�_t|t�s|j|d�}|jd�|dz
}|j||j
j�ddd�y#1swY��$xYw#1swYyxYw)N)�source�lineno�offsetrurU�replace�
rN)r3r\rRrhr5rr�r��
end_lineno�
end_offset�text�
isinstancer4�decode�split�assertIn)	rrsr�r�r�r�rA�cm�lines	         r�checkzExceptionTests.check�s+��
�\�\��V�F�\�
C�	7��"�"�;�/�
3�2���\�6�2�
3����R�\�\�0�0�&�9����R�\�\�0�0�&�9��%�� � ����!8�!8�*�E��%�� � ����!8�!8�*�E��|�|� � �,�!�#�s�+��*�*�X�y�9�C��y�y���v�a�x�0���
�
�d�B�L�L�$5�$5�6�	7�	7�
3�
3��	7�	7�s"�E(�E�DE(�E%	� E(�(E1c�0�|j}|ddd�y)Nz"\
"(1 for c in I,\
\��r��rr�s  r�)test_error_offset_continuation_charactersz8ExceptionTests.test_error_offset_continuation_characters�s���
�
��
�*�A�q�1rc��|j}|ddd�|ddd�|ddd�|d	dd
�|ddd
�|ddd
d��|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$�|d4dd$�|d5dd$d6��|d7dd8�|d9dd�|d:dd�|d;dd�|d<d=d>�|d?dd@�|dAdd@�|dBddC�|dDdd�|dEdd@�|dFdd�|dGddH�|dIdd�|dJdd�|dKdd�|dLdd�|dMdd�|dNdd�|dOdd�|dPdd�|dQdd�|dRdd�|dSdd�|dTdd�|dUdd�|dVdd�y)WNzdef fact(x):
	return x!
r�rGz1 +
rN�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:
  passztry:
  pass
except*:
  pass�z6try:
  pass
except*:
  pass
except* ValueError:
  passz(0x+1)zx = 0xIz0010 + 2z
x = 32e-+4zx = 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�s  r�testSyntaxErrorOffsetz$ExceptionTests.testSyntaxErrorOffset�sg���
�
��
�+�Q��3�
�g�q�!��
�2�A�r�:�
�#�Q��+�
�;�Q��C�
�L���h�	(�
�2�A�r�:�
�h��1��
���A�&�
�n�a��#�
�,�a��4�
�+�Q��2�
�1�1�a�8�
�,�a��3�
�-�q�!�4�
�I�1�b�Q�
�o�q�!�$�
�m�Q��"�
�"�A�q�!�R�0�
�'��A�q�"�5�
�"�A�q�!�R�0�
�%�q�!�Q��3�	�"�A�r�*�
�$�a��+�
�!�1�a�(�
�I�1�a�P�
�.��1�5�
�K�Q�PQ�R�	�h��1��
�i��A��
�j�!�Q��
�l�A�q�!�
�i��A��
�n�a��#�
���A�&�
�8�!�Q�"�	$�
�	��B�		�	�8�!�Q�?�
�f�a���
�%�q�!�,�
�C�Q��K�
����	�	����	�	��
��	�	�1�1�a�8�
�+�Q��3�
�$�a��,�
�C�Q��K�
�'��A�.�
�.��1�5�
�l�A�q�!�
�2�A�q�9�	�3�Q��:�
�-�q�!�4�
�4�a��;�
�j�!�Q��
�%�q�!�,�
� �!�Q�'�
�.��1�5�
�!�1�a�(�
�o�q�!�$�
�!�1�a�(rz)Downcasting to int is safe for col_offset�cpur�F)�memuse�dry_runc��d|dfz}|jtd�5t|dd�ddd�y#1swYyxYw)Nsif True:
%*sspasszParser column offset overflowrurU)�assertRaisesRegexrMrh)r�sizerss   r�testMemoryErrorBigSourcez'ExceptionTests.testMemoryErrorBigSourceGsD���$���0��
�
#�
#�M�3R�
S�	/��C��v�.�	/�	/�	/�s�5�>c�����Gd�dt��Gd�d����fd�}��fd�}��fd�}|�|�|�y)Nc��eZdZd�Zy)�9ExceptionTests.testSettingException.<locals>.BadExceptionc��td��)Nzcan't instantiate BadException)rP)�self_s rrzBExceptionTests.testSettingException.<locals>.BadException.__init__Us��"�#C�D�DrNrr!rr�BadExceptionr�Ts��
Err�c��eZdZy)�=ExceptionTests.testSettingException.<locals>.InvalidExceptionN�rrr r!rr�InvalidExceptionr�X���rr�c�N��ddl}	|j�d��jd�y#t$rp}|jj
j}�j|jd��j|jjd��Yd}~yd}~wwxYw)NrrN�Expected exception�
test_capi1�test_exceptions.py)�	_testcapi�raise_exceptionrirX�
__traceback__�tb_frame�f_coder5�co_name�
assertTrue�co_filename�endswith)r�r6�cor�rs   ��rr�z7ExceptionTests.testSettingException.<locals>.test_capi1[s�����
0��)�)�,��:��	�	�.�/���
O��&�&�/�/�6�6��� � ����\�:������� 7� 7�8L� M�N�N��
O�s�+�	B$�A&B�B$c����ddl}	|j�d��jd�y#t$r�}|jj
}|jj}�j|jd��j|jjd��|jjj}�j|jd�Yd}~yd}~wwxYw)Nrr�rr��
test_capi2)r�r�rirPr��tb_nextr�r�r5r�r�r�r��f_back)r�r6�tbr��co2r�rs     ��rr�z7ExceptionTests.testSettingException.<locals>.test_capi2fs�����

0��)�)�,��:��	�	�.�/�� �
<��&�&�.�.���[�[�'�'��� � ����Z�8������� 7� 7�8L� M�N��k�k�(�(�/�/��� � ����l�;�;��

<�s�+�	C,�B.C'�'C,c�R��ddl}�jt|j�d�y)NrrN)r�r\rVr�)r�r�rs ��r�
test_capi3z7ExceptionTests.testSettingException.<locals>.test_capi3ts#�������k�9�+D�+D�.��
3rr))rr�r�r�r�r�s`   @@r�testSettingExceptionz#ExceptionTests.testSettingExceptionOs;���
	E�9�	E�	�	�		0�	0�	3�
	�����rc��	t|jtt�|jt	td��d�|jt	tdd��d�tddd�}|j|j
d�|j|jd�|jt	|�d�td	ddd
�}|j|j
d�|j|jd
�|j|jd�|j|jd�|j|jd�|jt	|�d�td	ddd�}|j|j
d
�|j|jd�|j|jd�|j|jd�|j|jd�|jt	|�d�tdd�}|j|j
d�|j|jd�|j|jd�|j|jd�|j|jd�y#t$rYywxYw)Ni��1001�messagez[Errno 1001] messager��foo�barz[Errno 9] foo: 'bar'rr�r�z[WinError 3] foo: 'bar'�z[WinError 1001] foo)�WindowsError�assertIsrCr5r4�errno�winerror�strerror�filename�	filename2rL)rr>s  r�test_WindowsErrorz ExceptionTests.test_WindowsError}s6��$	0��
�M�M�,��0����S����/��8����S���y�!9�:�3�
5���5�%�(�A����Q�W�W�a�(����Q�Z�Z��.����S��V�%;�<���5�%��+�A����Q�W�W�a�(����Q�Z�Z��+����Q�Z�Z��/����Q�Z�Z��/����Q�[�[�$�/����S��V�%>�?���5�$��-�A����Q�W�W�b�)����Q�Z�Z��.����Q�Z�Z��/����Q�Z�Z��.����Q�[�[�$�/����S��V�%:�;���u�%�A����Q�W�W�e�,����Q�Z�Z��.����Q�Z�Z��/����Q�Z�Z��.����Q�[�[�$�/��E�	��	�s�K�	K�K�win32ztest specific to Windowsc��	td�}d}|jtd|z�5|jj	|�ddd�y#1swYyxYw)N�ctypeslcs�@zWindows Error 0x%x)rr�rC�	pythonapi�PyErr_SetFromWindowsErr)rr��codes   r�test_windows_messagez#ExceptionTests.test_windows_message�sV��	I��x�(����
�
#�
#�G�-A�D�-H�
I�	;����4�4�T�:�	;�	;�	;�s�A
�
Ac�\�tdiddiftdiddiftdiddiftdiddiftdiddd�ftdidddddd�ftd	id	dddd
d�ftdid	dddd
d�ftd
id	ddd�ftdiddddd�ftdidddddd�ftdidddddddd�ftdiddddddddd�ftdidd ddddd!d"d#d$�	ftd%idd%dddddddd&�	ftdiddift
d'id'd(d)d*d+d,�ftd(td-�d*dd+fid(td-�d*dd+fd(d-d*d+d,�ftd.id.d(d-d*d+d,�ftd/id/d0d1d*dd2�ftdiddd3�ftdiddd3�ftdtd4d5�6�tdd4d5�7�fg}	|jtdiddddddd8�f�|D�]W\}}}}	||i|��}t!|�j"j%d9�s%|j't!|�j(d:�t+|�}|D]D}t-||�}	|j't/|	�t/||�|�d;|�d<|	�d=||����Ft0fD]�}
t3|
j4dz�D]�}|
j7||�}|
j9|�}|D]X}t/t-||��}
|tk(r|d5k(rt/d�}nt/||�}|j'|
|d>|�d?|����Z������Zy#t$rY��jwxYw#t;d@|�dA|��t<j>�B�Y���xYw)CNr!�args)rN)r�)r�rNr�)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�)rNr�r�)rNr�rN)r�r�r�r�r�)rtr�r�r�r�r��print_file_and_line)�msgStrr�)r�r�r�rtr�r�r�r�)r�)r��	linenoStr�	offsetStr�textStr�endLinenoStr�endOffsetStrr�r�r�r�r�)	r�r�r�r�rtr�r�r�r�)r�r�r�r�r�r�r��print_file_and_lineStr)	r�r�r�rtr�r�r�r�r�)�ascii�arrN�ordinal not in ranger�r�rr�)r�rA�object�start�reason��)r�r�rrNr�)�あrrN�ouchr�r�)r�r�r�r��end)r�r�name�obj�rr)r�rr)r�r�r�r�r�r�r�builtins�.z == z, expected z	pickled "z", attribute "z
exc=z, args=)�file) �
BaseExceptionrWrCrR�UnicodeError�UnicodeEncodeError�UnicodeDecodeError�	bytearray�UnicodeTranslateErrorrr#r;�dict�appendr�rL�typerr�r5rr4r]�repr�picklerg�HIGHEST_PROTOCOL�dumpsrc�printr^�stderr)r�
exceptionListr0r��kwargs�expectedror{�checkArgName�value�p�protocol�new�got�wants               r�testAttributeszExceptionTests.testAttributes�s����B��V�b�M�2�
�E�2����7�
�H�b��(�#�
%�
�J���*�%�
'�
��2�"�U�3�
5�
�h��"��T��d�4�
5��n�b�(�"�$� �u�6�
7��+�R�(�#�4� �u�6�
7��9�2�(�u�6�R�
T�
�@�"�5�+�z�+�-�
.��7��,��+�+�4�A�
B��"�b�4�$�!�d�t�"�D�#B�
C��+�r�%��)-�x�"�t��#�%�
&�
�G�HJ�'�)�G�*.�x�+��-�^�
M�
N��5�68��5�*.�x�"�t��#�4�
9�	
:��2�r�F�R�>�2�
�":�;=�C�%�#��)?�A�
B� �'�9�W�+=�q�!�"8�":�;=�"�I�g�$6��1�+A�C�%�'��)?�A�
B� �":�;=�C�%�'��)?�A�
B�#�$<�b�2�$���a�)�
*��X�r�!��.�
0�
"�H�b�!��.�
0�
�X�t��U�'C��(��U�;�
=�iV
�
�n
	�� � ��@�"�0�"/�d� �"/�t�E�F�
�,9�#	@�'�C��v�x�"
@���(��(���A�w�'�'�0�0�1A�B��$�$�T�!�W�%7�%7��D���F��$,�E�L�#�A�|�4�E��$�$�T�%�[�%)�(�<�*@�%A�%&��%*�H�\�,B�&D�E�E�!��@�A�$)�!�*<�*<�q�*@�$A�
@���G�G�A�x�0���g�g�a�j��,4�
@�L�"&�w�s�L�'A�"B�C�"�n�4���9N�(,�D�z��'+�H�\�,B�'C�� �,�,�S�$�./��.?�@�
@�
@�@�+#	@���	��	��
H���s�g�W�T�H�5�C�J�J�G�G�s�7 K5�#L�5	L�L�#L+c��td�}d|_|j|jd�|j|jd�|j	t
t|d�|j	t
t|d�|jddd��|j|jd�|j|jd�|j|jd�|j|jd�|jd	d
dd��|j|jd
�|j|jd�|j|jd	�|j|jd�y)
N�*�5)r"r��brNr�)r�r$r�)rNr�r��#)r�r��blah)
r*r&r5r�r\r;r]�__setstate__r�r$�rros  r�
test_setstatezExceptionTests.test_setstate9s&���b�M������������'��������$����.�'�1�c�:����.�'�1�c�:�	���Q�a�(�)��������'��������$�������a� �������a� �	���R��"�=�>��������)��������$�������b�!�������a� rc��td�}|jtd�5|jd�ddd�y#1swYyxYw)Nr"zstate is not a dictionary)r*r�rXr'r(s  r�test_invalid_setstatez$ExceptionTests.test_invalid_setstateKs=���b�M��
�
#�
#�I�/J�
K�	�
�N�N�2��	�	�	�s	�=�Ac���td�td�td�fD�]�}|j|��5|j	t|d��|j
d�|j|jdg�|jt�5|j
d�ddd�|j|jdg�|j
d�|j|jddg�|`|j	t|d��|j
d	�|j|jd	g�d|_|j|jd�|jt�5|j
d
�ddd�|j|jd�ddd����y#1swY��xYw#1swY�>xYw#1swY���xYw)NrNr�r��ro�	__notes__zMy Noter"z	Your NotezOur Notez
will not work)rr*rYr3�assertFalse�hasattr�add_noter5r.r\rXr(s  r�
test_noteszExceptionTests.test_notesPs�����"�I�a�L�*�Q�-�@�	2�A������"�
2�� � ���K�!8�9��
�
�9�%�� � ����y�k�:��&�&�y�1�#��J�J�r�N�#�� � ����y�k�:��
�
�;�'�� � ����y�+�.F�G��K�� � ���K�!8�9��
�
�:�&�� � ����z�l�;� ���� � ����b�1��&�&�y�1�0��J�J��/�0�� � ����b�1�/
2�
2�	2�#�#�� 0�0��+
2�
2�s=�AG�G�(CG�?G�$G�G�G�G�G�G$	c�4�	td��#t$r}|j}Yd}~nd}~wwxYwt�j	|�}|j|t�|j
|j|�td�j	|�}|j|t�|j
|j|�Gd�dt�}|�j	|�}|j||�|j
|j|�y)Nr�r�c��eZdZy)�5ExceptionTests.testWithTraceback.<locals>.MyExceptionNr�r!rr�MyExceptionr5yr�rr6)rFr*r�r�with_traceback�assertIsInstancer5)rror�r6s    r�testWithTracebackz ExceptionTests.testWithTracebackks���	!��Q�-����	!����B��	!��
�O�*�*�2�.�����a��/�������"�-��q�M�(�(��,�����a��,�������"�-�	�)�	�
�M�(�(��,�����a��-�������"�-��
�	,�'�,c��	dt�_|jd�y#t$r%}|j	dt|��Yd}~yd}~wwxYw)Nr��No exception raisedz!__traceback__ must be a traceback)r*r�rirXr�r4r(s  r�testInvalidTracebackz#ExceptionTests.testInvalidTraceback�sJ��	-�()�I�K�%�
�I�I�+�,���	G��M�M�=�s�1�v�F�F��	G�s�#�	A�A�Ac��t}t�}d}|j||t|dd�d}|j||t|dd�d}|j||t|dd�d}|j||t|d	d�y)
Nz'int' object is not iterabler�rNz)__traceback__ must be a traceback or Noner�z9exception cause must be None or derive from BaseException�	__cause__z;exception context must be None or derive from BaseException�__context__)rXr*r��setattr)r�TEr0rts    r�test_invalid_setattrz#ExceptionTests.test_invalid_setattr�s���
���k��,�����r�3���f�a�@�9�����r�3���o�q�I�I�����r�3���k�1�E�K�����r�3���m�Q�Grc�$�t}	td��#t$r}|}Yd}~nd}~wwxYwd}|j||t|d�|j||t|d�|j||t|d�|j||t|d�y)Nr�zmay not be deletedr�r�r?r@)rXrFr*r��delattr)rrBror0rts     r�test_invalid_delattrz#ExceptionTests.test_invalid_delattr�s���
��	��Q�-����	��C��	��#�����r�3���f�=����r�3���o�F����r�3���k�B����r�3���m�Ds��	(�#�(c���	td��#t$r}|j}Yd}~nd}~wwxYwt�}||_d|_|j|jd�y)Nr�)rFr*r�r5)rror�s   r�testNoneClearsTracebackAttrz*ExceptionTests.testNoneClearsTracebackAttr�sU��	!��Q�-����	!����B��	!��
�K��������������$�/r:c��t�}|j|j�|j|j�t	�}|j|j�|j|j�Gd�dt
�}|�}|j|j�|j|j�y)Nc��eZdZy)�5ExceptionTests.testChainingAttrs.<locals>.MyExceptionNr�r!rrr6rK�r�rr6)r*�assertIsNoner@r?rXrC)rror6s   r�testChainingAttrsz ExceptionTests.testChainingAttrs�s����K�����!�-�-�(����!�+�+�&��K�����!�-�-�(����!�+�+�&�	�'�	�
�M�����!�-�-�(����!�+�+�&rc��	t��#t$r}|}Yd}~nd}~wwxYw|j|j�|j|j�|j	|j
�t
�|_d|_|j|jt�|j|j�|j|j
�d|_|j	|j
�y)NF)	r*rLr@r?r/�__suppress_context__rLr8r�)rr0ros   r�testChainingDescriptorsz&ExceptionTests.testChainingDescriptors�s���	��+����	��A��	��	
���!�-�-�(����!�+�+�&�����/�/�0�!���
�������a�m�m�Y�7����!�+�+�&�����.�.�/�!&�������/�/�0s�
�	!��!c��|jttd��Gd�dt�}|d��}|j|jd�y)NrN)r�c��eZdZd�Zy)�8ExceptionTests.testKeywordArgs.<locals>.DerivedExceptionc�<�tj|�||_yr)rr�	fancy_arg)rrUs  rrzAExceptionTests.testKeywordArgs.<locals>.DerivedException.__init__�s���&�&�t�,�!*��rNrr!rr�DerivedExceptionrS�s��
+rrVr")rU)r\rXrr5rU)rrVrs   r�testKeywordArgszExceptionTests.testKeywordArgs�sE��	
���)�]�a��8�	+�}�	+�

�r�*��������b�)rc�t����fd��|jt���fd��|jt��y)Nc�����Srr!)�fs�rrZz/ExceptionTests.testInfiniteRecursion.<locals>.f�s
����3�Jrc�2��	��S#t$rYywxYw)Nr��rY��gs�rr^z/ExceptionTests.testInfiniteRecursion.<locals>.g�s!���
��s�
���
��
�s�
�	�)r\rQ)rrZr^s @@r�testInfiniteRecursionz$ExceptionTests.testInfiniteRecursion�s/���	����.�!�,�	�
	
���.�!�,rc���|jtt��|jttd���|jttdd���y)Nr�r$)r�r4r*r+s r�test_strzExceptionTests.test_str�s?������I��'�����I�c�N�+�,�����I�c�3�/�0�1rc��	t��#t$r }|j|t�Yd}~nd}~wwxYw|jdt��|j	t
�5ddd�y#1swYyxYw�Nro�r*r8�assertNotIn�localsr\�UnboundLocalErrorr(s  r�test_exception_cleanup_namesz+ExceptionTests.test_exception_cleanup_names�sk��	0��+����	0��!�!�!�Y�/�/��	0������f�h�'�
�
�
�0�
1�	�
�	�	�	�s�
�	5�0�5�'A3�3A<c��	t��#t$r!}|j|t�~Yd}~nd}~wwxYw|jdt��|j	t
�5ddd�y#1swYyxYwrcrdr(s  r�test_exception_cleanup_names2z,ExceptionTests.test_exception_cleanup_names2�sm��	��+����	��!�!�!�Y�/���	��	
����f�h�'�
�
�
�0�
1�	�
�	�	�	�s�
�	6�1�6�(A4�4A=c�����Gd�dt��Gd�d�}��fd�}|��tj��}	|�d�t�|��|j	��|��tj��}	|�d�t�|��|j	��|��tj��}	|�d�t�|��|j	��|��tj��}dD]
}	|��d�t�|��|j	��|��tj��}		|�	|��tj��}	|�d�td��r
t�|��|j	��Gd	�d
�}|��tj��}|�5|�ddd�d�td��r
t�|��|j	��y#�$r}Yd}~���d}~wwxYw#�$rY���wxYw#Y��xYw#Y��9xYw#t
�xYw#t
$rL}d|_d�t�|��td��r
t�|j	��Yd}~��Md}~wwxYw#�$r		�#�xYw#�$rYnwxYwY��LwxYw#1swY��xYw)Nc��eZdZd�Zy)�=ExceptionTests.testExceptionCleanupState.<locals>.MyExceptionc��||_yr�r�rrs  rrzFExceptionTests.testExceptionCleanupState.<locals>.MyException.__init__	�	����rNrr!rrr6rm���
rr6c��eZdZy)�7ExceptionTests.testExceptionCleanupState.<locals>.MyObjNr�r!rr�MyObjrtr�rruc����}����rr!)�	local_refr6rs ��r�inner_raising_funczDExceptionTests.testExceptionCleanupState.<locals>.inner_raising_funcs����I��c�"�"r)rF)�cpythonc��eZdZd�Zd�Zy)�9ExceptionTests.testExceptionCleanupState.<locals>.Contextc��|Srr!r+s r�	__enter__zCExceptionTests.testExceptionCleanupState.<locals>.Context.__enter__o����rc��y)NTr!)r�exc_type�	exc_value�exc_tbs    r�__exit__zBExceptionTests.testExceptionCleanupState.<locals>.Context.__exit__qs��rN�rrr r}r�r!rr�Contextr{ns��
�
rr�)r*�weakref�refrrLrHr@r)	rrurx�wrro�ir�r6rs	       @@r�testExceptionCleanupStatez(ExceptionTests.testExceptionCleanupStates����	�)�	�	�	�	#��g��
�[�[��
��	�� ������d�����#���g��
�[�[��
��	�� ������d�����#���g��
�[�[��
��	�� ������d�����#���g��
�[�[��
���	�A�
�"�$�	�
�����d�����#���g��
�[�[��
��	#�
�"�$�$�g��
�[�[��
��		�� ����U�+��L��d�����#��	�	�
�g��
�[�[��
��
�Y�	!�� �	!����U�+��L��d�����#���G�	���	���	��	��	���
���
�����	#�
!�A�M��C��L��$�C� ��/������c�"�"��	#��&�	�
�������
��
���	��,	!�	!�s��H1�I�I�I�'I!�K�0K#�1I�<I�I
�I
�I�I�!I)�)I,�,	K�5AJ<�<K�K �K�K�K�K�K �K�K �K �#K,c�X���fd�}	ty#t$r�|�Yd��yd��wwxYw)Nc�
���yrr!r-s�r�print_errorzIExceptionTests.test_exception_target_in_nested_scope.<locals>.print_error�s���
r)�	somethingr*)rr�ros  @r�%test_exception_target_in_nested_scopez4ExceptionTests.test_exception_target_in_nested_scope}s'���	�	����	��M�M��	�s��	)�$�)c�B�d�}|�}|jt|�t�|jt	j
��|jt|�t�|jt	j
��|jt|��	t
d��#t$r�|�}|jt|�t�|jt	j
�t�|jt|�t�|jt	j
�t�|jt|�t�~|jt	j
�t�YywxYw)Nc3��K�	td��#t$r/tj���tj���YnwxYwtj���y�w)N�caught)rHr^rr!rr�yield_raisez:ExceptionTests.test_generator_leaking.<locals>.yield_raise�sK����
&��x�(�(���
&��m�m�o�%��m�m�o�%�
&���-�-�/�!�s �A!��5A�A!�A�A!r�)r8�nextrHrLr^rrX)rr�r^s   r�test_generator_leakingz%ExceptionTests.test_generator_leaking�s��	"�
�M�����d�1�g�x�0����#�-�-�/�*����d�1�g�x�0����#�-�-�/�*����$�q�'�"�
	>��E�"�"���	>��
�A��!�!�$�q�'�8�4��!�!�#�-�-�/�9�=��!�!�$�q�'�8�4��!�!�#�-�-�/�9�=��!�!�$�q�'�9�5���!�!�#�-�-�/�9�=�	>�s�*B5�5C&F�Fc���d�}	t�#t$r|�}t|�YnwxYw	t|�n#t$rYnwxYw|jt	j
��y)Nc3�K�d��y�wrr!r!rrr^z1ExceptionTests.test_generator_leaking2.<locals>.g�s	�������)rPr��
StopIterationrLr^r�rr^�its   r�test_generator_leaking2z&ExceptionTests.test_generator_leaking2�sa��	�	�����	���B���H�	��	���H���	��	�����#�-�-�/�*s��)�)�9�	A�Ac��d�}|�}t|�	ddz|j
tj��y#t$ru}|jtj�|�|j|�}|jtj�|�|j||�Yd}~��d}~wwxYw)Nc3�`K�	d��y#t$rtj���YywxYw�wr�rZr^rr!rrr^z1ExceptionTests.test_generator_leaking3.<locals>.g�s(����
&���$�
&��m�m�o�%�
&�s�.�	�.�+�.�+�.rNr)r�rZr�r^r�throwrL)rr^r�ro�gen_excs     r�test_generator_leaking3z&ExceptionTests.test_generator_leaking3�s���	&�
�S���R��	&�
�a�C�	
���#�-�-�/�*��!�	&��M�M�#�-�-�/�1�-��h�h�q�k�G��M�M�#�-�-�/�1�-��M�M�'�1�%�%��		&�s�A�	B>�	A+B9�9B>c�l�d�}|�}	t�#t$rtt|��}YnwxYw|j|t�	t|�n:#t$r.}|jtj�|�Yd}~nd}~wwxYw|jtj��y)Nc3�`K�	ddzy#t$rtj����wxYw�w�NrNrr�r!rrr^z1ExceptionTests.test_generator_leaking4.<locals>.g�s/����
��!���$�
��m�m�o�%��
�s�.�
�.�!+�.)rXrr�r�rZr^rrL)rr^r��tpros     r�test_generator_leaking4z&ExceptionTests.test_generator_leaking4�s���	��S��	 ��O���	 ��d�2�h��B�	 ��	
�
�
�b�+�,�	.���H��!�	.��M�M�#�-�-�/�1�-�-��	.��	
���#�-�-�/�*s$��2�2�A�	B�!$B
�
Bc����fd�}|�}	t�#t$rt|�YnwxYw�jtt|�y)Nc3��K��jtj�t�d���j	tj��y�wr)r8r^rrPrLr+s�rr^z>ExceptionTests.test_generator_doesnt_retain_old_exc.<locals>.g�s4������!�!�#�-�-�/�<�@�����c�m�m�o�.�s�AA)rPr�r\r�r�s`  r�$test_generator_doesnt_retain_old_excz3ExceptionTests.test_generator_doesnt_retain_old_exc�sD���	/��S��	�����	���H�	�����-��r�2s��,�,c�~��d���fd�}|�t�|jtj��y)Nc3�K�d��y�w�NrNr!r!rr�
simple_genzNExceptionTests.test_generator_finalizing_and_sys_exception.<locals>.simple_gen�s�����G�r�c�T����}	t�#t$rt|�cYSwxYwr)rPr�)�genr�s �r�run_genzKExceptionTests.test_generator_finalizing_and_sys_exception.<locals>.run_gen�s.����,�C�
!�"�"���
!��C�y� �
!�s��'�')rrLr^r)rr�r�s  @r�+test_generator_finalizing_and_sys_exceptionz:ExceptionTests.test_generator_finalizing_and_sys_exception�s-���	�	!�	�	������#�-�-�/�*rc����Gd�dt��Gd�d�}��fd�}|��tj��}|�}t|�||�dx}�t	�|��|j��y)Nc��eZdZd�Zy)�FExceptionTests._check_generator_cleanup_exc_state.<locals>.MyExceptionc��||_yrrorps  rrzOExceptionTests._check_generator_cleanup_exc_state.<locals>.MyException.__init__rqrNrr!rrr6r�rrrr6c��eZdZy)�@ExceptionTests._check_generator_cleanup_exc_state.<locals>.MyObjNr�r!rrrur�r�rruc3�<�K�	����#�$rd��YywxYw�wrr!)r6rs��r�raising_genzFExceptionTests._check_generator_cleanup_exc_state.<locals>.raising_gens(�����
�!�#�&�&���
��
�s��
�	���)r*r�r�r�rrL)r�testfuncrur�r�r^r6rs      @@r�"_check_generator_cleanup_exc_statez1ExceptionTests._check_generator_cleanup_exc_state�sm���	�)�	�	�	�	��g��
�[�[��
���M���Q��������C����d�����#�rc�,�d�}|j|�y)Nc�V�	|jt��y#t$rYywxYwr)r�rPr]s r�do_throwzGExceptionTests.test_generator_throw_cleanup_exc_state.<locals>.do_throws'��
������'���
��
�s��	(�(�r�)rr�s  r�&test_generator_throw_cleanup_exc_statez5ExceptionTests.test_generator_throw_cleanup_exc_states��	�
	
�/�/��9rc�,�d�}|j|�y)Nc�$�|j�yr)r`r]s r�do_closezGExceptionTests.test_generator_close_cleanup_exc_state.<locals>.do_closes��
�G�G�Irr�)rr�s  r�&test_generator_close_cleanup_exc_statez5ExceptionTests.test_generator_close_cleanup_exc_states��	��/�/��9rc�,�d�}|j|�y)Nc��d}yrr!r]s r�do_delzCExceptionTests.test_generator_del_cleanup_exc_state.<locals>.do_del$s���Arr�)rr�s  r�$test_generator_del_cleanup_exc_statez3ExceptionTests.test_generator_del_cleanup_exc_state#s��	��/�/��7rc�2���fd�}�j|�y)Nc�^��	t|��jd�y#t$rYywxYw�Nz should have raised StopIteration)r�rir��r^rs �r�do_nextzEExceptionTests.test_generator_next_cleanup_exc_state.<locals>.do_next)s2���
>��Q���	�	�<�=��!�
��
�s� �	,�,r�)rr�s` r�%test_generator_next_cleanup_exc_statez4ExceptionTests.test_generator_next_cleanup_exc_state(����	>�	
�/�/��8rc�2���fd�}�j|�y)Nc�j��	|jd��jd�y#t$rYywxYwr�)�sendrir�r�s �r�do_sendzEExceptionTests.test_generator_send_cleanup_exc_state.<locals>.do_send3s6���
>����t���	�	�<�=��!�
��
�s�&�	2�2r�)rr�s` r�%test_generator_send_cleanup_exc_statez4ExceptionTests.test_generator_send_cleanup_exc_state2r�rc���G�fd�d�}d�	t|���#YnxYwt�|j��y)Nc���eZdZ�fd�Zy)�*ExceptionTests.test_3114.<locals>.MyObjectc�.��tj��yr)r^rr(s �r�__del__z2ExceptionTests.test_3114.<locals>.MyObject.__del__@s����M�M�O�rN�rrr r�r-s�r�MyObjectr�?s���
$rr�r!)r*rrL)rr�ros  @r�	test_3114zExceptionTests.test_3114<sC���	$�	$�
��	��H�J�'�'��	��������!�s�!�%c���Gd�dt�}Gd�dt�}Gd�dt�}		|�#|$r�}|}	|�#|$r�}|}	|�#|$r�}|}	|j||�|j||�|j|	|�|j|j�|j	|j|�|j	|	j|�|�d}~wwxYwd}~wwxYwd}~wwxYw#|$r}
|
}Yd}
~
nd}
~
wwxYw|j	|�|j	|j	�|j	|	j�|j|j�y)Nc��eZdZy)�HExceptionTests.test_raise_does_not_create_context_chain_cycle.<locals>.ANr�r!rr�Ar�Lr�rr�c��eZdZy)�HExceptionTests.test_raise_does_not_create_context_chain_cycle.<locals>.BNr�r!rr�Br�Nr�rr�c��eZdZy)�HExceptionTests.test_raise_does_not_create_context_chain_cycle.<locals>.CNr�r!rr�Cr�Pr�rr�)r*r8rLr@r�)rr�r�r��a_r��b_r$�c_�cror0s            r�.test_raise_does_not_create_context_chain_cyclez=ExceptionTests.test_raise_does_not_create_context_chain_cycleKsM��	�	�	�	�	�	�	�	�	�	�
 �����
 ��� ��G��� ��A�
 ����� ����-�-�a��3��-�-�a��3��-�-�a��3��)�)�!�-�-�8��
�
�a�m�m�Q�7��
�
�a�m�m�Q�7���� ��	 ��	
 ��"�	��C��	��	
�
�
�c�1���
�
�a�m�m�Q�'��
�
�a�m�m�Q�'����!�-�-�(sf�2�C-�C(�<�C%�C �A�C�B
C�C�C � C%�%C(�(C-�-C0�0D�5C<�<Dc��d�}	|�|jt�|j|jt�|j|jj|j�y#t$r}|}Yd}~�wd}~wwxYw)Nc�`�	td��#t$r}||_td��d}~wwxYw�NrNr�)rYr@rX��exs r�cyclezBExceptionTests.test_no_hang_on_context_chain_cycle1.<locals>.cyclevs2��
#� ��m�#���
#�!#�����l�"��
#�s�
�	-�(�-)r*r8rXr@rYr�)rr�ror0s    r�$test_no_hang_on_context_chain_cycle1z3ExceptionTests.test_no_hang_on_context_chain_cycle1ssj��	#�	��G�	
���c�9�-����c�o�o�z�:��
�
�c�o�o�1�1�3�?�?�C���	��C��	�s�A3�3	B�<B�Bc��Gd�dt�}Gd�dt�}Gd�dt�}|j|�5}	|��#|$r>}|}	|��#|$r'}|}	|��#|$r}	|	}
|
|_|
�d}	~	wwxYwd}~wwxYwd}~wwxYw#1swYnxYw|jj
�|j|
j�|j|j�|j|j|
�y)Nc��eZdZy)�>ExceptionTests.test_no_hang_on_context_chain_cycle2.<locals>.ANr�r!rrr�r��r�rr�c��eZdZy)�>ExceptionTests.test_no_hang_on_context_chain_cycle2.<locals>.BNr�r!rrr�r��r�rr�c��eZdZy)�>ExceptionTests.test_no_hang_on_context_chain_cycle2.<locals>.CNr�r!rrr�r��r�rr��r*r\r@r�r)rr�r�r�r��_ar��_br$�_cr�s           r�$test_no_hang_on_context_chain_cycle2z3ExceptionTests.test_no_hang_on_context_chain_cycle2�s���	�	�	�	�	�	�	�	�	��
�
�q�
!�	 �R�

 ��c�	���
 ���	 ��#�I��� ��A� ��c�	��� ���()��
���� ��	 ��	
 ��	 �	 �� 	
�
�
�b�l�l�A�&��
�
�a�m�m�Q�'��
�
�a�m�m�Q�'��
�
�a�m�m�Q�'se�B�A�B�
B�A�B�A>�A&�&A;	�+A6	�6A;	�;A>�>B�B�B�B�Bc��Gd�dt�}Gd�dt�}Gd�dt�}Gd�dt�}Gd	�d
t�}|j|�5}	|��#|$r\}|}	|��#|$rE}	|	}
	|��#|$r.}|}||_	|��#|$r}
|
}|�}|�d}
~
wwxYwd}~wwxYwd}	~	wwxYwd}~wwxYw#1swYnxYw|jj�|j|j�|j|j�|j|j
�|j|
j�|j|j|�y)Nc��eZdZy)�>ExceptionTests.test_no_hang_on_context_chain_cycle3.<locals>.ANr�r!rrr�r�r�rr�c��eZdZy)�>ExceptionTests.test_no_hang_on_context_chain_cycle3.<locals>.BNr�r!rrr�r�r�rr�c��eZdZy)�>ExceptionTests.test_no_hang_on_context_chain_cycle3.<locals>.CNr�r!rrr�r�r�rr�c��eZdZy)�>ExceptionTests.test_no_hang_on_context_chain_cycle3.<locals>.DNr�r!rr�Dr�r�rr	c��eZdZy)�>ExceptionTests.test_no_hang_on_context_chain_cycle3.<locals>.ENr�r!rr�Er�r�rrr�)rr�r�r�r	rr�r�r�r�r$r�r��_d�dros                r�$test_no_hang_on_context_chain_cycle3z3ExceptionTests.test_no_hang_on_context_chain_cycle3�sb��	�	�	�	�	�	�	�	�	�	�	�	�	�	�	��
�
�q�
!�	$�R�
$��c�	���
$���$��#�I���$��A�
$��c�	���$���()��
�$�"#�#�I�� �$� "�A� !��A�"#�G��$��$��	$��	
$��	$�	$��*	
�
�
�b�l�l�A�&��
�
�a�m�m�Q�'��
�
�a�m�m�Q�'��
�
�a�m�m�Q�'��
�
�a�m�m�Q�'��
�
�a�m�m�Q�'s��C
�A&�&C�+C�.A5�5B?�:B:�=B�B7	�		B2	�B�B/�B*�*B/�/B2	�2B7	�7B:�:B?�?C�C�C
�
Cc���		td�}|�#td�}|�xYw#t$r}|}Yd}~nd}~wwxYw|j|�|j|j�yr�)rXrYr*r�r@)r�te�veror0s     r�,test_context_of_exception_in_try_and_finallyz;ExceptionTests.test_context_of_exception_in_try_and_finally�s`��	�
��q�\�������]������	��C��	��	
�
�
�c�2���
�
�c�o�o�r�*s�
��!�	6�1�6c�@�		td�}|�#td�}|�xYw#td�}|�xYw#t$r}|}Yd}~nd}~wwxYw|j	|�|j	|j
�|j	|j
j
�y)NrNr�r�)rXrYrCr*r�r@)rrr�oeror0s      r�/test_context_of_exception_in_except_and_finallyz>ExceptionTests.test_context_of_exception_in_except_and_finally�s���	�
��q�\�����
���]������Q�Z������	��C��	��	
�
�
�c�2���
�
�c�o�o�r�*��
�
�c�o�o�1�1�2�6s$�
��"�0�3�	A�A�Ac��			td�}|�#YnxYw	td�}|�#td�}|�xYw#t$r}|}Yd}~nd}~wwxYw|j|�|j|j�yr�)rYrCr*r�r@)rrrror0s     r�-test_context_of_exception_in_else_and_finallyz<ExceptionTests.test_context_of_exception_in_else_and_finally�s���	�	
�� ��]�����	
����
�Q�Z������Q�Z������	��C��	��	
�
�
�c�2���
�
�c�o�o�r�*s)�
&��&�
7�4�7�	A�A�Ac��tddddd�}|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�y)Nr��xxxxxrNr�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	r5r4rr�rAr�r
r)r�us  r�test_unicode_change_attributesz-ExceptionTests.test_unicode_change_attributess���
�u�g�q�!�U�;������Q��![�\��������Q��!`�a����'�������Q��!m�n���
�����Q��!n�o��������Q��!q�r��u�h��1�e�<������Q��!V�W��������Q��!X�Y����'�������Q��!h�i���
�����Q��!i�j��������Q��!l�m�!�&�!�Q��6������Q��!R�S��������Q��!W�X����'�������Q��!d�e��������Q��!g�hrc��tttf}|D],}|jt	|j|��d��.y)N�)r	r
rr5r4�__new__)r�klasses�klasss   r�test_unicode_errors_no_objectz,ExceptionTests.test_unicode_errors_no_object0s=��$�&8�:O�O���	<�E����S����u�!5�6��;�	<rc���Gd�dt�}Gd�dt|��}t�5}	t��#|$r}|j	d�Yd}~n%d}~wt$rYn|j	d�YnxYwddd�n#1swYnxYw�fd����}|j|tt|��|jd	t|��y)
Nc��eZdZd�Zy)�/ExceptionTests.test_badisinstance.<locals>.Metac��t��rr\)�cls�subclasss  r�__subclasscheck__zAExceptionTests.test_badisinstance.<locals>.Meta.__subclasscheck__;s
�� �l�"rN)rrr r*r!rr�Metar&:s��
#rr+c��eZdZy)�6ExceptionTests.test_badisinstance.<locals>.MyExceptionNr�r!rrr6r-=r�rr6)�	metaclasszShould have raised KeyErrorz%exception should not be a MyExceptionc�D��	��S#t$r}|cYd}~Sd}~wwxYwr)rQ)ror^s �rr^z,ExceptionTests.test_badisinstance.<locals>.gLs$���
��s�
��!�
����
�s�
�	���z maximum recursion depth exceeded)	rr*rrHrir8rQr�r4)rr+r6rror0r^s      @r�test_badisinstancez!ExceptionTests.test_badisinstance6s����	#�4�	#�	�)�t�	��
�
	9�&�	
9��j� ���
C��	�	�A�B�B���
��
9��	�	�7�8��
	9�
	9�
	9��	�
�c�����c�>�4��9�=��
�
�8�#�c�(�Cs7�B�
8�A5�A�B�A5�B�!A5�3B�B
c�@�d�}|�tj�y)Nc�P�t�}td�D]}|j}�y)Ni@B)r�rg�__dir__)�ors  rr�z3ExceptionTests.test_trashcan_recursion.<locals>.foo[s(����A��9�%�
���I�I��
r)rr)rr�s  r�test_trashcan_recursionz&ExceptionTests.test_trashcan_recursionVs��
	�	�����rc���dtz}tjdd|�\}}}|j|d�|j	d|�|j	d|�|j	d|�y)Na�if 1:
            import sys
            from _testinternalcapi import get_recursion_depth
            from test import support

            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()
            try:
                recurse(support.EXCEEDS_RECURSION_LIMIT)
            finally:
                sys.setrecursionlimit(recursionlimit)
                print('Done.')
        �-Wd�-crNsRecursionErrorsResourceWarning�Done.)�__file__r	�assert_python_failurer5r��rr��rc�outr6s     r�$test_recursion_normalizing_exceptionz3ExceptionTests.test_recursion_normalizing_exceptionesn��$�H�I$��J%�:�:�5�$��M���C������Q���
�
�'��-��
�
�(�#�.��
�
�h��$rc��d}tjd|�\}}}|j|d�|jd|�|jd|�y)Nz�if 1:
            import _testcapi
            try:
                raise _testcapi.RecursingInfinitelyError
            finally:
                print('Done.')
        r8rNs0RecursionError: maximum recursion depth exceededr9)r	r;r5r�r<s     r�-test_recursion_normalizing_infinite_exceptionz<ExceptionTests.test_recursion_normalizing_infinite_exception�sP��
��%�:�:�4��F���C������Q���
�
�I�3�O��
�
�h��$rc�z����d�}�fd���fd���fd��tj�}	|d����fD]6}|j|��5	|�|jd�ddd��8	tj
|�y#t$rY�,wxYw#1swY�hxYw#tj
|�wxYw)Nc��d}		tj|�	tj||z�y#t$r|dz
}YnwxYw�Er�)r^�setrecursionlimitrQ)�n�depths  r�set_relative_recursion_limitzUExceptionTests.test_recursion_in_except_handler.<locals>.set_relative_recursion_limit�sS���E����)�)�%�0���!�!�%��'�*��	&���Q�J�E���s�4�A�Ac�.��	ddzy#��YyxYwr�r!)�recurse_in_excepts�rrIzJExceptionTests.test_recursion_in_except_handler.<locals>.recurse_in_except�s���
$��!���
$�!�#�s�	�	c�.��	ddz��y#Y�xYwr�r!)�recurse_after_excepts�rrKzMExceptionTests.test_recursion_in_except_handler.<locals>.recurse_after_except�s!���
��!��
!�"��
��s��c�2��	��y#��YyxYwrr!)�recurse_in_body_and_excepts�rrMzSExceptionTests.test_recursion_in_except_handler.<locals>.recurse_in_body_and_except�s���
-�*�,��
-�*�,�s��	rG)�funcz#Should have raised a RecursionError)r^�getrecursionlimitr3rirQrD)rrG�recursionlimitrNrKrMrIs    @@@r� test_recursion_in_except_handlerz/ExceptionTests.test_recursion_in_except_handler�s����		+�	$�	#�	-��.�.�0��	2�(��,�*�,@�B\�]�
I���\�\�t�\�,�I�I����	�	�"G�H�
I�I�
I�
�!�!�.�1��*�����I�I��
�!�!�.�1�sG�"B#�
B�B�B�'
B#�	B�B�B�B�B 	�B#�#B:c��d}t�5tjd|�\}}}|jd|�ddd�y#1swYyxYw)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)
        r8�MemoryError)r
r	r;r�r<s     r�)test_recursion_normalizing_with_no_memoryz8ExceptionTests.test_recursion_normalizing_with_no_memory�sL����!�
"�	/�(�>�>�t�T�J�L�B��S��M�M�.�#�.�	/�	/�	/�s�-A�Ac�l����ddl�ddlm����fd�}|�}|�}�j||�y)Nr��raise_memoryerrorc���	���jd��j�S#t$r}|j}Yd}~�+d}~wwxYw)Nz Should have raised a MemoryError)rirKr��	format_tb)ror�rWr�	tracebacks  ���r�
raiseMemErrorz6ExceptionTests.test_MemoryError.<locals>.raiseMemError�sI���
>�!�#��	�	�<�=��&�&�r�*�*��	�
%��_�_���
%�s�,�	A�A�A)rZr�rWr5)rr[�tb1�tb2rWrZs`   @@r�test_MemoryErrorzExceptionTests.test_MemoryError�s0���	�/�	+��o���o������c�"rc��ddl}d}d}|jt|jd�|jd�}|j	t|�t
�|j
t|t��|j|j�|jd|�}|j|j|�|jd|��}|j
t||��Gd	�d
t�}|jd|||f�}|j
t||��|j
t||��|j|j|�|jdd
|ddi�}	|j
t|	|��|j|	jd�|j|	jd
�y)NrzThis is a test docstring.zThis is another test docstring.�error1z_testcapi.error1z_testcapi.error2z_testcapi.error3)�basec��eZdZy)�1ExceptionTests.test_exception_with_doc.<locals>.CNr�r!rrr�rcr�rr�z_testcapi.error4z_testcapi.error5rr�rN)r�r\rV�make_exception_with_docr�rr��
issubclassr*rL�__doc__r5r�r�)
rr��doc2�doc4r`�error2�error3r��error4�error5s
          r�test_exception_with_docz&ExceptionTests.test_exception_with_docs����*��0�����+�y�'H�'H�"�	$��2�2�3E�F���
�
�d�6�l�D�)����
�6�9�5�6����&�.�.�)��2�2�3E�t�L���������.��2�2�3E�8>�3�@�����
�6�6�2�3�	��	��2�2�3E�t�4:�A�;�@�����
�6�6�2�3����
�6�1�-�.��������.��2�2�3E�r�39�C��8�E�����
�6�6�2�3�������1�%��������,rc�
����ddlm�Gd�d��d����fd�}	|�|jd�t�|j
��d�y#t$r!}|j	��d�Yd}~�Gd}~wwxYw)NrrVc��eZdZy)�3ExceptionTests.test_memory_error_cleanup.<locals>.CNr�r!rrr�rp3r�rr�c�L����}tj|����yr�r�r�)r�r�rWr�s ���r�innerz7ExceptionTests.test_memory_error_cleanup.<locals>.inner6s�����A����Q��B��rzMemoryError not raised)r�rWrirK�assertNotEqualrr5)rrsror�rWr�s   @@@r�test_memory_error_cleanupz(ExceptionTests.test_memory_error_cleanup.ss���	0�	�	�
��	 �	0��G�
�I�I�.�/��������t�$���	,������d�+�+��	,�s�A�	B�!A=�=Bc�����Gd�d��d����fd��	��|jd�t�|j	��d�y#t$r!}|j��d�Yd}~�Gd}~wwxYw)Nc��eZdZy)�6ExceptionTests.test_recursion_error_cleanup.<locals>.CNr�r!rrr�rxHr�rr�c�L����}tj|����yrrr)r�r�rsr�s ���rrsz:ExceptionTests.test_recursion_error_cleanup.<locals>.innerKs�����A����Q��B��GrzRecursionError not raised)rirQrtrr5)rror�rsr�s  @@@r�test_recursion_error_cleanupz+ExceptionTests.test_recursion_error_cleanupEsn���	�	�
��	�	3��G�
�I�I�1�2��������t�$���	,������d�+�+��	,�s�A�	A<�A7�7A<c��|jt�5}tjt�ddd�|jjjtj|j�y#1swY�IxYwr)	r\rC�os�listdirr:r5rr��ENOTDIR)rr�s  r�test_errno_ENOTDIRz!ExceptionTests.test_errno_ENOTDIRZsW��
�
�
�w�
'�	!�2��J�J�x� �	!�������+�+�U�]�]�B�L�L�I�	!�	!�s�A8�8Bc�8�Gd�d�}|�}tj�5}~t�|j|jj
|j�|j|jj�ddd�y#1swYyxYw)Nc��eZdZd�Zy)�1ExceptionTests.test_unraisable.<locals>.BrokenDelc��td�}|�)Nz
del is brokenr\�rr0s  rr�z9ExceptionTests.test_unraisable.<locals>.BrokenDel.__del__cs�� ��1���	rNr�r!rr�	BrokenDelr�bs��
rr�)	r�catch_unraisable_exceptionrr5�
unraisabler�r��assertIsNotNone�
exc_traceback)rr�rr�s    r�test_unraisablezExceptionTests.test_unraisable`sx��	�	��k��
�
/�
/�
1�	>�R���L����R�]�]�1�1�9�3D�3D�E�� � ����!<�!<�=�	>�	>�	>�s�A!B�Bc	�d�ttfD]}|j|�5	|d�}|�y#|$rGt�5}t	j
t	j��ddd�n#1swYnxYwYnwxYwj�}|jd|�|jd|�|j|j|�|tur|jd|�n|jd|�|j|jd��ddd���#1swY��"xYw)Nztest messager�z	raise excz<exception str() failed>r�)rYr'r3rr^�__excepthook__�exc_info�getvaluer�rr�r�)rr�r0r�reports     r�test_unhandledzExceptionTests.test_unhandledps��#�%7�8�	7�H����h�'�
7�<�"�>�2�C��I�	7�� �<�(�*�<�f��*�*�C�L�L�N�;�<�<�<��<�� ���*���
�
�2�F�;��
�
�k�6�2��
�
�h�/�/��8��1�1��M�M�"<�f�E��M�M�.�&�9�������� 5�6�!
7�
7�
7�s>�D%�
/�A;�%A,	�#	A;�,A5
�1A;�8D%�:A;�;B D%�%D/	c��d}tdd�D]C}tjd||z�\}}}|j|d�|jd|��Ey)Nz�if 1:
            import _testcapi
            class C(): pass
            _testcapi.set_nomemory(0, %d)
            C()
        rNr�r8)rN�xrS)rgr	r;r�)rr�r�r=r>r6s      r�"test_memory_error_in_PyErr_PrintExz1ExceptionTests.test_memory_error_in_PyErr_PrintEx�sX�����q�"��	/�A�(�>�>�t�T�A�X�N�L�B��S��M�M�"�h�'��M�M�.�#�.�	/rc����Gd�dt��Gd�dt����fd�}|�}|jd�|j��5|j���ddd�y#1swYyxYw)Nc��eZdZy)�BExceptionTests.test_yield_in_nested_try_excepts.<locals>.MainErrorNr�r!rr�	MainErrorr��r�rr�c��eZdZy)�AExceptionTests.test_yield_in_nested_try_excepts.<locals>.SubErrorNr�r!rr�SubErrorr��r�rr�c3�P�K�	���#�$r	d���#�$rY�wxYwwxYw�wrr!)r�r�s��r�mainz=ExceptionTests.test_yield_in_nested_try_excepts.<locals>.main�sF�����
��k�!���
����� ������
�s(�&��#��#��#��#�&)r*r�r\r�)rr��coror�r�s   @@r� test_yield_in_nested_try_exceptsz/ExceptionTests.test_yield_in_nested_try_excepts�se���	�	�	�	�y�	�	��v���	�	�$��
�
�
�y�
)�	#��J�J�x�z�"�	#�	#�	#�s�A0�0A9c����fd�}|�}	t�#t$r�jt|�d�YnwxYw�jt|�d�y)Nc3��K�	t�#t$rd��YnwxYw�jtj��d��y�wr�)rYrLr^rr+s�rr^z?ExceptionTests.test_generator_doesnt_retain_old_exc2.<locals>.g�s?�����
� � ���
���
�����c�m�m�o�.��G�s�A��
�A��+ArNr�)rFr5r�)rr^r�s`  r�%test_generator_doesnt_retain_old_exc2z4ExceptionTests.test_generator_doesnt_retain_old_exc2�sS���	��c��	+�����	+����T�#�Y��*�	+������c��A�&s��$<�<c��d�}|jt�5|�}	ddzddd�y#t|�t|�Y�#xYw#1swYyxYw)Nc3�K�d����wr�r!r!rrr^z1ExceptionTests.test_raise_in_generator.<locals>.g�s�����G��r�rNr)r\rZr�)rr^r�s   r�test_raise_in_generatorz&ExceptionTests.test_raise_in_generator�sZ��	�
�
�
�0�
1�	���A�
��!��	�	��
��Q���Q���
	�	�s�A
�0�A
�A
�
Az Won't work if __debug__ is Falsec���ta	b|jd�y#t$r<}b|j	|t�|jt
|�d�Yd}~yd}~wwxYw)Nr��hello)rX�AssertionErrorrirr8r5r4r(s  r�test_assert_shadowingz$ExceptionTests.test_assert_shadowing�s\��
#��	,���I�I�*�+��
�	.���!�!�!�^�4����S��V�W�-�-��	.�s�	A �2A�A c���Gd�dt�}	t�#t$r}|}Yd}~nd}~wwxYw	|�#t$rYnwxYwtd�D])}	t�#t$r
}Yd}~nd}~wwxYwt��+y)Nc��eZdZy)�BExceptionTests.test_memory_error_subclasses.<locals>.TestExceptionNr�r!rr�
TestExceptionr��r�rr�rG)rKr*rgr)rr�r0�inst�_s     r�test_memory_error_subclassesz+ExceptionTests.test_memory_error_subclasses�s���	�K�	�	�����	��D��	��	�����	��	���r��	�A�
�!�!���
���
��
�L�
	s.��	,�'�,�2�	>�>�A�	A)�$A)c��dtj�d�}tjd|�\}}}|j	d|�y)NzOif 1:
            import _testcapi
            _testcapi.run_in_subinterp("[0]*z")
            exit(0)
        r8rS)r^�maxsizer	�assert_python_okr�)rr�r=r�r6s     r�test_memory_error_in_subinterpz-ExceptionTests.test_memory_error_in_subinterp�sD��.�.1�k�k�]�;	���
#�3�3�D�$�?�
��A�s��
�
�n�c�*r)NNr?)Vrrr r9rpr|r�r�r�r��unittest�skipIfrr^r�r�requires_resource�
bigmemtestr�rr�r��
skipUnless�platformr�r r)r+r2r9r=rCrFrHrMrPrWrr_rarhrjr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr#r0r5r?rArQrTr^rmrurzrr�r�r�r�r�r�r�r�r�r!rrr.r.+s���4�RC�hI�0'Q�R7�"2�a)�F�X�_�_�W����+�-X�Y��W���u�%��W�����5�9�/�:�&�Z�/�
�+��+�Z%0�N�X�������0�3�5�;�5�;�I@�V!�$�
2�6.�*-�
H�E�	0�'� 1�$*��
-��
-�2�	�	�w�r�>�<
+�+�&+�6
3�+��2:�:�
8�
9�9�
�&)�PD�&"(�H-(�^+�7�$+�$#i�J<��D��D�>��W���u�%��&����4%��4%�l�%��%�",2�^�/��/�*�#��#�$�%-��%-�N�%��%�,�%��%�(J�>� 7�*�/��/� #�.'�$
��X����$F�G�
,�H�
,��<+rr.c�$�eZdZd�Zd�Zd�Zd�Zy)�NameErrorTestsc�v�	ty#t$r&}|jd|j�Yd}~yd}~wwxYw)N�bluch)r�rLr5rr�s  r�test_name_error_has_namez'NameErrorTests.test_name_error_has_names1��	0����	0����W�c�h�h�/�/��	0�s�	�	8�3�8c�&���fd�}	|��j
dj��y#�j$rQtj�5}tjtj
��ddd�n#1swYnxYwY��wxYw)Nc�h���jtd�5tddd�y#1swYyxYw)N�aaa)r�rL�aabr+s�rrZz)NameErrorTests.test_issue45826.<locals>.fs+����'�'�	�5�9�
��
�
�
�s�(�1r�)�failureExceptionrrr^r�r�r�r��rrZr6s`  r�test_issue45826zNameErrorTests.test_issue45826sv���	�	4�
�C�
	
�
�
�e�S�\�\�^�,��	�$�$�	4��(�(�*�
4�c��"�"�C�L�L�N�3�
4�
4�
4��	4�s'�0�#B�%B�8	B�B
	�B�Bc�T�d�}	|�|j
dj��|j
d|j��y#t$rQtj�5}tjtj
��ddd�n#1swYnxYwY��wxYw)Nc�j�	ty#t$r }|jd�t��d}~wwxYwr)�nonsenserr7rZ)rs rrZz1NameErrorTests.test_issue45826_focused.<locals>.f!s1��
*��� �
*�� � ��&�'�)�)��
*�s�	�	2�-�2r�rZ)rZrrr^r�r�r�r�r�s   r�test_issue45826_focusedz&NameErrorTests.test_issue45826_focused s���	*�	4�
�C�
	
�
�
�j�#�,�,�.�1��
�
�)�3�<�<�>�:��!�	4��(�(�*�
4�c��"�"�C�L�L�N�3�
4�
4�
4��	4�s)�A
�
B'�*%B�	B'�B!	�B'�&B'c�6�d�}|jt|�y)Nc���G�fd�d��y)Nc���eZdZW�y)�;NameErrorTests.test_gh_111654.<locals>.f.<locals>.TestClassNr���	TestClasss�rr�r�3s���rr�r!r�s@rrZz(NameErrorTests.test_gh_111654.<locals>.f2s
���
�
r)r\rL�rrZs  r�test_gh_111654zNameErrorTests.test_gh_1116541s��	�	
���)�Q�'rN)rrr r�r�r�r�r!rrr�r�s��0�-�;�"(rr�c��eZdZd�Zd�Zd�Zy)�AttributeErrorTestsc�&�td�}|j|j�|j|j�t	�}tdd|��}|j|jd�|j
|j|�y)NzOuch!�Ouch�carryr)r;rLrrr�r5r�)rr0�sentinels   r�test_attributesz#AttributeErrorTests.test_attributes<sk���W�%�����#�(�(�#����#�'�'�"��8���V�'�x�@��������7�+��
�
�c�g�g�x�(rc��Gd�d�}|�}	|j	t
j
|d�y#t$rB}|jd|j�|j||j�Yd}~�^d}~wwxYw#t$rB}|jd|j�|j||j�Yd}~yd}~wwxYw)Nc��eZdZdZy)�<AttributeErrorTests.test_getattr_has_name_and_obj.<locals>.AN�rrr �blechr!rrr�r�Hs���Err�r�)r�r;r5rrr��__getattribute__�rr�rr0s    r�test_getattr_has_name_and_objz1AttributeErrorTests.test_getattr_has_name_and_objGs���	�	��c��	+��I�I�	+��#�#�C��1��	�	+����W�c�h�h�/����S�#�'�'�*�*��	+��
�	+����W�c�h�h�/����S�#�'�'�*�*��	+�s,�7�B�	B�8A=�=B�	C�8C�Cc���Gd�d�}|�}	|j�y#t$rB}|jd|j�|j||j�Yd}~yd}~wwxYw)Nc��eZdZd�Zy)�GAttributeErrorTests.test_getattr_has_name_and_obj_for_method.<locals>.Ac��yrr!r+s rr�zMAttributeErrorTests.test_getattr_has_name_and_obj_for_method.<locals>.A.blechYs��rNr�r!rrr�r�Xs��
rr�r�)r�r;r5rrr�s    r�(test_getattr_has_name_and_obj_for_methodz<AttributeErrorTests.test_getattr_has_name_and_obj_for_methodWs^��	�	��c��	+��I�I�K���	+����W�c�h�h�/����S�#�'�'�*�*��	+�s�$�	A/�8A*�*A/N)rrr r�r�r�r!rrr�r�;s��	)�+� 
+rr�c�$�eZdZd�Zd�Zd�Zd�Zy)�ImportErrorTestsc�Z�td�}|j|j�|j|j�tdd��}|j	|jd�|j|j�tdd��}|j	|jd�|j|j�tddd��}|j	|jd�|j	|jd�d}|jt|�5tdd	�
�ddd�|jt|�5tddd	��ddd�|jt|�5tdd
d	��ddd�|jt|�5td	�
�ddd�|jt|�5tdd	d��ddd�y#1swY��xYw#1swY��xYw#1swY�zxYw#1swY�[xYw#1swYyxYw)N�test�
somemodule�r�somepath��path�somename)r�rz8'invalid' is an invalid keyword argument for ImportError�keyword)�invalidr)rr�r�)r�r�T)r��another)rDrLrr�r5r�rX)rr0rts   rr�z ImportErrorTests.test_attributeshs����&�!�����#�(�(�#����#�(�(�#��&�|�4��������<�0����#�(�(�#��&�z�2��������:�.����#�(�(�#��&�z�
�C��������:�.�������:�.�H��
�
#�
#�I�s�
3�	3���	�2�	3��
#�
#�I�s�
3�	@���V�Y�?�	@��
#�
#�I�s�
3�	@���V�Y�?�	@��
#�
#�I�s�
3�	+��	�*�	+��
#�
#�I�s�
3�	A���	�4�@�	A�	A�	3�	3��	@�	@��	@�	@��	+�	+��	A�	A�s<�(G1�G=�H	�.
H�H!�1G:�=H�	H�H�!H*c��tddd��}|j|jd�|j|jd�|j|jd�|j|j
d�|j
�|j|jd�|j|jd�|j|jd�|j|j
d�y)Nr�rr��rr��r�r!)rDr5r�rtrr�rr�s  r�test_reset_attributesz&ImportErrorTests.test_reset_attributes�s����&�v�F�;��������9�-�������&�)�������6�*�������6�*�	����������2�&�������$�'�������4�(�������4�(rc��tdtfd��5d}t|�}|jt	|�t	|��ddd�y#1swYyxYw)NrT)�quietsabc)r�BytesWarningrDr5r4)r�argr0s   r�test_non_str_argumentz&ImportErrorTests.test_non_str_argument�sM��
�R��.�d�
;�	1��C��c�"�C����S��X�s�3�x�0�	1�	1�	1�s�2A�Ac��t�td��td��tdd��fD�]�}tdi|��}ttjdz�D]�}tj
tj||��}|j|jd�|j|jd�|j|j|j�|j|j|j���tjtjfD]�}||�}|j|jd�|j|jd�|j|j|j�|j|j|j������y)	Nr�r�r�r�r�r�rNr�)r
rDrgrrrcrr5r�rtrr��copy�deepcopy)rr�orig�protor0r�s      r�test_copy_picklez!ImportErrorTests.test_copy_pickle�sP���v���,���,���*�=�?�	6�F��0��0�D��v�6�6��:�;�
6���l�l�6�<�<��e�#<�=��� � ����9�5�� � ����&�1�� � ����4�9�9�5�� � ����4�9�9�5�
6��Y�Y��
�
�-�
6����g��� � ����9�5�� � ����&�1�� � ����4�9�9�5�� � ����4�9�9�5�
6�	6rN)rrr r�r�r�rr!rrr�r�fs�� A�D)�1�6rr�c�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)�SyntaxErrorTestsc�j�dtd�fdtd�fdtd�fdtd�fdtd	�fd
td	�fdtd	�fdtd	�fd
td�fg	}|D]$\}}|j|��5	td|��y#t$rz}tj�5}tjtj��ddd�n#1swYnxYw|j|j��|}Yd}~nd}~wwxYw	ddd���#1swY��xYw)N)�bad.pyrNr��abcdefgrNr�z�
               File "bad.py", line 1
                 abcdefg
                  ^^^^^
             SyntaxError: bad bad
             )rrNr�rrNr�z�
               File "bad.py", line 1
                 abcdefg
                  ^
             SyntaxError: bad bad
             )rrNr�rrN���)rrNr�rrNr�z�
               File "bad.py", line 1
                 abcdefg
                    ^
             SyntaxError: bad bad
             )rrN���rrNrzn
               File "bad.py", line 1
                 abcdefg
             SyntaxError: bad bad
             )rrNrrrN���)rrNrrrNr)rrNrrrNr��rrNr�rrN�dz�
               File "bad.py", line 1
                 abcdefg
                  ^^^^^^
             SyntaxError: bad bad
             )r��bad bad)
rr3rRrrr^r�r�r�r�)r�casesr�rr0r6�
the_exceptions       r�test_range_of_offsetsz&SyntaxErrorTests.test_range_of_offsets�s���/�
���
�/�
���
�0�
���
�/�
���
�1�
���
�1�
���
�/�
���
�/�
���
�1�
���
�MN
��^$�	(�N�D�(����4��(�
(�(�%�i��6�6�	(��#�(� �0�0�2�<�c��*�*�C�L�L�N�;�<�<�<���M�M�(�C�L�L�N�;�$'�M��	(��"�
(�
(�
(�sH�	D)�B�	D�"D�6%C$	�	D�$C-
�))D�D)�D�D)�)D2	c�"�d}	ttdd��5}|j|�ddd�tjdddt�\}}}|jd�j
�}|j|d	d
�|j|dd�tt�d
}	ttdd��5}|j|�ddd�tjdddt�\}}}|jd�j
�}|j|d	d�|j|dd�tt�y#1swY��*xYw#tt�wxYw#1swY��xYw#tt�wxYw)NuU# -*- coding: cp437 -*-
"¢¢¢¢¢¢" + f(4, x for x in range(1))
r>�cp437r@r7�-X�utf8r?���u@    "┬ó┬ó┬ó┬ó┬ó┬ó" + f(4, x for x in range(1))rz-                          ^^^^^^^^^^^^^^^^^^^z# -*- coding: ascii -*-

(
r�z    (z    ^)	r_r�writer	r;r��
splitlinesr5r
)rr��testfiler=r>r6s      r�test_encodingszSyntaxErrorTests.test_encodings
sX��
M�	�		��f�c�G�4�
'�����v�&�
'�(�>�>�u�d�F�TZ�[�L�B��S��*�*�W�%�0�0�2�C����S��W�&h�i����S��W�&U�V��6�N�2��		��f�c�G�4�
'�����v�&�
'�(�>�>�u�d�F�TZ�[�L�B��S��*�*�W�%�0�0�2�C����S��W�g�.����S��W�g�.��6�N�+
'�
'��
�6�N��

'�
'��
�6�N�sG�E�E�A1E�+E=�=E1�A1E=�E�E�E.�1E:�6E=�=Fc�`�	ttd�5}|jd�ddd�tjdddt�\}}}|jd�j
�}|jd|d�tt�y#1swY�mxYw#tt�wxYw)	N�bw��r7rrr?z8SyntaxError: Non-UTF-8 code starting with '\x89' in filer�)	r_rrr	r;r�rr�r
)rrr=r>r6s     r�
test_non_utf8zSyntaxErrorTests.test_non_utf8*s���	��f�d�#�
(�x����w�'�
(�(�>�>�u�d�F�TZ�[�L�B��S��*�*�W�%�0�0�2�C��M�M�U�WZ�[]�W^�_��6�N�
(�
(��
�6�N�s"�B�B�AB�B�B�B-c��d}td|�}|\}}}}}}|j||j�|j||j�|j||j�|j||j
�|j||j�|j||j�|jd|j�y)Nr
r�	rRr5r�r�r�r�r�r�rt)	rr�rr�r�r��errorr�r�s	         r�test_attributes_new_constructorz0SyntaxErrorTests.test_attributes_new_constructor6s���2��#�I�t�4�
�BF�?��&�&�%��Z�����=�#9�#9�:������!5�!5�6�����]�%=�%=�>������!5�!5�6�����]�%=�%=�>�����
� 2� 2�3�����M�$5�$5�6rc��d}td|�}|\}}}}|j||j�|j||j�|jd|j�|j||j
�|jd|j�|j||j�|jd|j�y)N)rrNr�rrr)rr�rr�r�r�rs       r�test_attributes_old_constructorz0SyntaxErrorTests.test_attributes_old_constructorBs���*��#�I�t�4�
�*.�'��&�&�%�����=�#9�#9�:������!5�!5�6�����}�7�7�8������!5�!5�6�����}�7�7�8�����
� 2� 2�3�����M�$5�$5�6rc��d}|jttd|�d}|jttd|�d}|jttd|�y)N)rrNr�r)rrNr�r�r�r�r�)rrNr�rrN)r\rXrR�rr�s  r�test_incorrect_constructorz+SyntaxErrorTests.test_incorrect_constructorNsM�������)�[�)�T�B�+�����)�[�)�T�B�-�����)�[�)�T�BrN)	rrr rrrr r"r%r!rrrr�s#��X(�t�:
�
7�
7�Crrc��eZdZd�Zy)�TestInvalidExceptionMatcherc��|jt�5	t�#d$rYnwxYw	ddd�n#1swYnxYw|jt�5	t�#tdf$rYnwxYw	ddd�y#1swYyxYw)Nr")r\rXrYr+s r�'test_except_star_invalid_exception_typezCTestInvalidExceptionMatcher.test_except_star_invalid_exception_typeZs���
�
�
�y�
)�	�
� � ���
��
���		�	�	���
�
�y�
)�	�
� � ����#�
��
���		�	�	�sF�3��&�3�&�3�<�A7�A�A*�'A7�)A*�*A7�7BN)rrr r)r!rrr'r'Ys��rr'c�N�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
y)
�PEP626Testsc��	|�|jd�g}j}|r[|j}|j|j�dn"|j|jjz
�|j}|r�[|jt|�|�y#t$r}|j}Yd}~��d}~wwxYw)Nr<)rir*r�r�r�r�f_linenor��co_firstlinenor5�tuple)rrZrr��t�lines�frames       r�lineno_after_raisezPEP626Tests.lineno_after_raisejs���	-�
�C�
�I�I�+�,���
�I�I����J�J�E��L�L����.�����u�|�|�:�:�:�
��	�	�A�
�	
����u��x�0���	!�� � �A��	!�s�B!�!	C�*B;�;Cc�.�d�}|j|d�y)Nc��ddzyr�r!r!rr�simplez:PEP626Tests.test_lineno_after_raise_simple.<locals>.simple}s��
�a�C�rrN�r3)rr6s  r�test_lineno_after_raise_simplez*PEP626Tests.test_lineno_after_raise_simple|s��	�	
�����*rc�.�d�}|j|d�y)Nc�(�	ddzy#ddzYyxYwr�r!r!rr�	in_exceptz@PEP626Tests.test_lineno_after_raise_in_except.<locals>.in_except�s��
��!���
��!���s��r�r7)rr;s  r�!test_lineno_after_raise_in_exceptz-PEP626Tests.test_lineno_after_raise_in_except�s��	�	
���	�1�-rc�.�d�}|j|d�y)Nc�<�	ddzy#t$r
}Yd}~yd}~wwxYwr�)rXr�s r�other_exceptz@PEP626Tests.test_lineno_after_other_except.<locals>.other_except�s!��
��!����
���
�s��	�r�r7)rr?s  r�test_lineno_after_other_exceptz*PEP626Tests.test_lineno_after_other_except�s��	�
	
����a�0rc�.�d�}|j|d�y)Nc�F�	ddzy#t$r}ddzYd}~yd}~wwxYwr�r)r�s r�in_named_exceptz@PEP626Tests.test_lineno_in_named_except.<locals>.in_named_except�s(��
��!����
��!����
�s��	 �� r�r7)rrCs  r�test_lineno_in_named_exceptz'PEP626Tests.test_lineno_in_named_except�s��	�	
�����3rc�.�d�}|j|d�y)Nc��	ddzy#wxYwr�r!r!rr�in_tryz.PEP626Tests.test_lineno_in_try.<locals>.in_try�s��
��!�����s��
r�r7)rrGs  r�test_lineno_in_tryzPEP626Tests.test_lineno_in_try�s��	�
	
�����*rc�.�d�}|j|d�y)Nc�&�		ddzy#ddzwxYwr�r!r!rr�in_finally_normalzDPEP626Tests.test_lineno_in_finally_normal.<locals>.in_finally_normal�s"��
���!�����!���s�r�r7)rrKs  r�test_lineno_in_finally_normalz)PEP626Tests.test_lineno_in_finally_normal����	�	
��� 1�1�5rc�.�d�}|j|d�y)Nc�.�	ddzddzy#ddzwxYwr�r!r!rr�in_finally_exceptzDPEP626Tests.test_lineno_in_finally_except.<locals>.in_finally_except�s&��
��!���!�����!���s�
�r�r7)rrPs  r�test_lineno_in_finally_exceptz)PEP626Tests.test_lineno_in_finally_except�rMrc�H��Gd�d���fd�}|j|d�y)Nc��eZdZd�Zd�Zy)�0PEP626Tests.test_lineno_after_with.<locals>.Noopc��|Srr!r+s rr}z:PEP626Tests.test_lineno_after_with.<locals>.Noop.__enter__�r~rc��yrr!r$s  rr�z9PEP626Tests.test_lineno_after_with.<locals>.Noop.__exit__�s��rNr�r!rr�NooprT�s��
�
rrWc�J����5ddz	ddd�y#1swYyxYwr�r!)rWs�r�
after_withz6PEP626Tests.test_lineno_after_with.<locals>.after_with�s'�����
��!���
�
�
�s��"r�r7)rrYrWs  @r�test_lineno_after_withz"PEP626Tests.test_lineno_after_with�s$���	�	�
	�	
���
�A�.rc��d�}|j|d�|jjd��|_|j|d�y)Nc��ddzyr�r!r!rrrZz8PEP626Tests.test_missing_lineno_shows_as_none.<locals>.f�s	��
�a�CrrNs�������)�co_linetable)r3�__code__r�r�s  r�!test_missing_lineno_shows_as_nonez-PEP626Tests.test_missing_lineno_shows_as_none�sA��	�����1�%��Z�Z�'�'�5T�'�U��
�����4�(rc�J��Gd�d���fd�}|j|dd�y)Nc��eZdZd�Zd�Zy)�CPEP626Tests.test_lineno_after_raise_in_with_exit.<locals>.ExitFailsc��|Srr!r+s rr}zMPEP626Tests.test_lineno_after_raise_in_with_exit.<locals>.ExitFails.__enter__�r~rc��t�rr\r$s  rr�zLPEP626Tests.test_lineno_after_raise_in_with_exit.<locals>.ExitFails.__exit__�s�� � rNr�r!rr�	ExitFailsrb�s��
�
!rrec�H����5ddzddd�y#1swYyxYwr�r!)res�rrYzDPEP626Tests.test_lineno_after_raise_in_with_exit.<locals>.after_with�s$�����
��!��
�
�
�s��!rNr7)rrYres  @r�$test_lineno_after_raise_in_with_exitz0PEP626Tests.test_lineno_after_raise_in_with_exit�s&���	!�	!�	�	
���
�A�q�1rN)rrr r3r8r<r@rDrHrLrQrZr_rgr!rrr+r+hs9��1�$+�.�1�4�+�6�6�
/�)�
2rr+�__main__)+r�r|r^r�rr�r��textwrapr�test.supportrrrrrr	r
�test.support.import_helperr�test.support.os_helperrr
�test.support.warnings_helperrr�rr�rrDr*rr#r'�TestCaser.r�r�r�rr'r+rr�r!rr�<module>ros(���	�
��
����/�/�/�5�1�7���!��Y���I��
+��+�]+�X�&�&�]+�@7+(�X�&�&�+(�`&+�(�+�+�&+�VJ6�x�(�(�J6�XdC�x�(�(�dC�N�(�"3�"3��k2�(�#�#�k2�Z�z���H�M�M�O���}E���G��s�D"�"D,�+D,