
    5\hdx                    d   d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlm	Z	 d dl
mZmZmZmZmZmZmZ d dlmZ d dlmZmZ d dlmZ d dlmZ 	 d dlmZ n# e$ r d	ZY nw xY w G d
 de          Z G d de          Z  G d de          Z! G d dej"                  Z#dZ$ G d dej"                  Z% G d dej"                  Z& G d dej"                  Z' G d dej"                  Z( G d dej"                  Z) G d dej"                  Z*e+dk    r ej,                     dS dS )    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                       e Zd Zd ZdS )NaiveExceptionc                     || _         d S Nxselfr   s     >/opt/python-3.11.14/usr/lib/python3.11/test/test_exceptions.py__init__zNaiveException.__init__           N__name__
__module____qualname__r    r   r   r   r      s#            r   r   c                       e Zd ZdZd ZdS )SlottedNaiveExceptionr   c                     || _         d S r   r   r   s     r   r   zSlottedNaiveException.__init__#   r   r   N)r   r   r    	__slots__r   r!   r   r   r#   r#   !   s(        I    r   r#   c                       e Zd Zd ZdS )BrokenStrExceptionc                      t          d          )Nzstr() is broken	Exceptionr   s    r   __str__zBrokenStrException.__str__'   s    )***r   N)r   r   r    r,   r!   r   r   r'   r'   &   s#        + + + + +r   r'   c                      e Zd Zd Zd Zd Zd ZdOdZd Zd	 Z	 e
j        eej        k    d
           ej        d           ej        edd          d                                     Zed             Zd Z e
j        ej        dk    d          d             Zd Zd Zd Zd Zd 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( Z-d) Z.d* Z/d+ Z0d, Z1d- Z2d. Z3d/ Z4d0 Z5d1 Z6d2 Z7 e
j8        d3          d4             Z9d5 Z:d6 Z;d7 Z<d8 Z=d9 Z>d: Z?e"d;             Z@e ej        d          d<                         ZAed=             ZBed>             ZCd? ZDed@             ZEedA             ZFedB             ZGedC             ZHe"dD             ZIdE ZJdF ZKdG ZLedH             ZMdI ZNdJ ZOdK ZP e
j        ddL          dM             ZQdN ZRdS )PExceptionTestsc                 |   |                      ||          5  	  |d          # |$ r}t          |          }Y d }~nd }~ww xY w	  |d          # |$ r}t          |          }Y d }~nd }~ww xY w|                     ||           |                     |j        |           d d d            d S # 1 swxY w Y   d S )N)excexcnamespam)subTeststrassertEqualr   )r   r0   r1   errbuf1buf2s         r   raise_catchzExceptionTests.raise_catch.   s8   \\c7\33 
	4 
	4 c&kk!      3xx  c&kk!      3xx T4(((S\7333
	4 
	4 
	4 
	4 
	4 
	4 
	4 
	4 
	4 
	4 
	4 
	4 
	4 
	4 
	4 
	4 
	4 
	4sR   B1%A>B1AB1AA0A+&B1+A004B11B58B5c                 

   |                      t          d           |                     t          t          t          d           |                      t
          d           t          t          dd          }|                                 t          t          dd          }t          j	        }	 	 dd l
}|                    d	           n# t
          $ r Y nw xY w|t          _	        |                                 t          t                     n9# |t          _	        |                                 t          t                     w xY w|                      t          d
           |                     t          t          dd           |                      t          d           |                     t          t          d           |                      t           d           g }|                     t           |j        d           |                      t$          d           i }|                     t$          |j        d           |                      t&          d           |                      t(          d           |                      t*          d           t,          }n# t*          $ r Y nw xY w|                      t.          d           d}t1          d          D ]}||z  }|                      t2          d           |                      t4          d           |                      t6          d           t9          d           n# t6          $ r Y nw xY w|                      t:          d           |                      t<          d           t?          ddd            |                      d!           n# t<          $ r Y nw xY w|                      tB          d"           |                      tD          d#           |                     tD          t          j#        d           |                      tH          d$           g d%z    n# tH          $ r Y nw xY w|                      tJ          d&           |                     tJ          tL          d'           |                      tN          d(           ddz  }n# tN          $ r Y nw xY w|                      tP          d)           ddz  }n# tP          $ r
}Y d }~nd }~ww xY w|                      tR          d*           d S )+NAttributeErrorundefined_attributeEOFErrorwutf-8encodingrr   r   OSErrorzthis 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>execzTabError not raisedSystemError
SystemExit	TypeErrorr!   
ValueErrori   ZeroDivisionErrorr*   StopAsyncIteration)*r9   r;   assertRaisesgetattrsysr=   openr   closestdinmarshalloadsr   rC   rD   
__import__rF   __getitem__rH   rJ   rK   rL   undefined_variablerM   rangerP   rQ   rR   rU   rS   rT   compilefailrV   rW   exitrX   rY   chrrZ   r*   r[   )r   fp	savestdinrb   r   dummyes          r   testRaisingzExceptionTests.testRaising;   s   )9:::.'38MNNN:...&#000



&#000I			c""""    "CIHHJJJ6NNNN "CIHHJJJ6NNNN),,,'4)CSIIIm444+z3EFFF\222*amR888:...(AM5999*,?@@@m444K000#QQ$$8883ZZ 	 	EFAA~666)9:::m444%[[[[   DD )+=>>>:...@) ) ) ii-....  	m444\222*ch222K000"WWW$$\222*c6222*,?@@@1QQ &&&$$&K0001QQ###ttttt#+-ABBBBBs   .C D 
CD CD 6EJ 
J! J!)L9 9
MM?N& &
N32N3-P3 3
Q ?Q R   
R-,R-S 
S% S%c                 F      fd}d} ||d            |dd           d S )Nc                 <                        | |          5  	 t          | dd                               d           nB# t          $ r5}|j        |k    r                     d|d|j                   Y d }~nd }~ww xY wd d d            d S # 1 swxY w Y   d S )N)srcmsg
<fragment>rU   "failed to get expected SyntaxError	expected , got )r3   rh   ri   rR   rt   )rs   rt   ro   r   s      r   ckmsgz4ExceptionTests.testSyntaxErrorMessage.<locals>.ckmsg   s   #3// D DDCv666
 IIBCCCC	 # H H Hu||			333"FGGGHD D D D D D D D D D D D D D D D D Ds9   BAB
B+A<7B<BBBBzHif 1:
        try:
            continue
        except:
            passz'continue' not properly in loopz	continue
r!   r   ry   ss   `  r   testSyntaxErrorMessagez%ExceptionTests.testSyntaxErrorMessage   sV    	D 	D 	D 	D 	D 	a2333l=>>>>>r   c                 4    t           f fd	}d} ||d           d} ||d           d} ||d           d} ||d           d} ||d           d	} ||d
           d} ||d
           d} ||dt                     d} ||dt                     d S )Nc                     	 t          | dd                               d           d S # |$ r<}|j        |k    r&                    d|d|j                   Y d }~d S Y d }~d S d }~ww xY w)Nru   rU   rv   rw   rx   )rh   ri   rt   )rs   rt   	exceptionro   r   s       r   ry   z:ExceptionTests.testSyntaxErrorMissingParens.<locals>.ckmsg   s    @\6222
 		>?????	  D D D5C<<IIIsssAEEBCCCCCCCCC  <<<<<Ds   + A,+A''A,zprint "old style"z@Missing parentheses in call to 'print'. Did you mean print(...)?zprint "old style",zprint f(a+b,c)zexec "old style"z>Missing parentheses in call to 'exec'. Did you mean exec(...)?zexec f(a+b,c)zprint (a+b,c) $ 42zinvalid syntaxzexec (a+b,c) $ 42zif 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)rR   rS   rT   rz   s   `  r   testSyntaxErrorMissingParensz+ExceptionTests.testSyntaxErrorMissingParens   s   &1 	@ 	@ 	@ 	@ 	@ 	@ $aSTTT$aSTTTaSTTT"aQRRRaQRRR
 !a!"""a!""" .aLN^___KaExPPPPPr   Nr?   c                    |                      |||          5  |                     t                    5 }t          |dd           d d d            n# 1 swxY w Y   |                     |j        j        |           |                     |j        j        |           | |                     |j        j        |           | |                     |j        j	        |           |j        j
        it          |t                    s|                    |d          }|                    d          |dz
           }|                     ||j        j
                   d d d            d S # 1 swxY w Y   d S )N)sourcelinenooffsetru   rU   replace
rN   )r3   r\   rR   rh   r5   r   r   r   
end_lineno
end_offsettext
isinstancer4   decodesplitassertIn)	r   rs   r   r   r   r   rA   cmlines	            r   checkzExceptionTests.check   s   \\VF\CC 	7 	7"";// 32\62223 3 3 3 3 3 3 3 3 3 3 3 3 3 3R\0&999R\0&999%  !8*EEE%  !8*EEE| ,!#s++ :**Xy99Cyyvax0dBL$5666	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7s5   E#AE#A	E#A	C<E##E'*E'c                 .    | j         } |ddd           d S )Nz"\
"(1 for c in I,\
\   )r   r   r   s     r   )test_error_offset_continuation_charactersz8ExceptionTests.test_error_offset_continuation_characters   s$    
*Aq11111r   c                    | j         } |ddd            |ddd            |ddd            |d	dd
            |ddd
            |dddd            |ddd            |ddd            |ddd            |ddd            |ddd            |ddd            |ddd            |ddd            |ddd            |ddd            |ddd            |ddd             |d!dddd"            |d#dddd
            |d$dd%dd&            |d'dd%dd&            |d(dd            |d)dd            |d*dd            |d+dd            |d,dd-            |d.dd-            |d/dd            |d0dd%            |d1dd            |d2dd-            |d3dd             |d4dd%            |d5dd%            |d6dd%d7            |d8dd9            |d:dd            |d;dd            |d<dd            |d=d>d?            |d@ddA            |dBddA            |dCdd            |dD                                dddd            |dEdd             |dFddA            |dGdd            |dHddI            |dJdd            |dKdd            |dLdd            |dMdd            |dNdd            |dOdd            |dPdd            |dQdd            |dRdd            |dSdd            |dTdd            |dUdd            |dVdd            |dWdd            d S )XNzdef fact(x):
	return x!
r   rG   z1 +
rN      z def spam():
  print(1)
 print(2)   zPython = "Python" +   u   Python = "Ṕýţĥòñ" +s+   # -*- coding: cp1251 -*-
Python = "ϳ" +   cp1251r@   s   Python = "ϳ" +   zx = "a   zlambda x: x = 2zf{a + b + c}z[file for str(file) in []
]   u   a = « hello » « world »z[
file
for str(file)
in
[]
]z[file for
 str(file) in []]zages = {'Alice'=22, 'Bob'=23}	   z7match ...:
    case {**rest, "key": value}:
        ...z[a b c d e f]zfor x yfff:   zf(a for a in b, c)   zf(a for a in b if a, c)zf(a, b for b in c)      zf(a, b for b in c, d)zclass foo:return 1zdef f():
  continuezdef f():
  breakz4try:
  pass
except:
  pass
except ValueError:
  passztry:
  pass
except*:
  pass   z6try:
  pass
except*:
  pass
except* ValueError:
  passz(0x+1)zx = 0xIz0010 + 2z
x = 32e-+4zx = 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="""u   b"fooжжж"z!x = [(yield i) for i in range(3)]zdef f():
  from _ import *zdef f(x, x):
  passz3{i for i in range(5) if (j := 0) for j in range(5)}&   zdef f(x):
  nonlocal xzdef f(x):
  x = 1
  global xz
nonlocal xz def f():
  global x
  nonlocal xz#from __future__ import doesnt_existzfrom __future__ import bracesz#x=1
from __future__ import divisionzfoo(1=2)zdef f():
  x, y: intz[*x for x in xs]zfoo(x for x in range(10), 100)zfor 1 in []: passz(yield i) = 2zdef f(*):
  pass)r   encoder   s     r   testSyntaxErrorOffsetz$ExceptionTests.testSyntaxErrorOffset   s   
+Q333gq!2Ar:::#Q+++;QCCCLh	( 	( 	( 	(2Ar:::h1A&&&na###,a444+Q22211a888,a333-q!444I1bQQQoq!$$$mQ""""Aq!R000'Aq"555"Aq!R000%q!Q333 	"Ar***$a+++!1a(((I1aPPP.1555KQPQRRR 	h1iAj!QlAq!!!iAna###A&&&8!Q"	$ 	$ 	$ 	$ 	 B		 		 		 	8!Q???fa%q!,,,CQKKK  	 	 	 	  	 	 	 	 
 	 	 	 	n##%%q!Q333 	11a888+Q333$a,,,CQKKK'A....1555lAq!!!2Aq999 	3Q:::-q!4444a;;;j!Q%q!,,, !Q'''.1555!1a(((oq!$$$!1a(((((r   z)Downcasting to int is safe for col_offsetcpur   F)memusedry_runc                     d|dfz  }|                      t          d          5  t          |dd           d d d            d S # 1 swxY w Y   d S )Ns   if True:
%*ss   passzParser column offset overflowru   rU   )assertRaisesRegexrM   rh   )r   sizers   s      r   testMemoryErrorBigSourcez'ExceptionTests.testMemoryErrorBigSourceH  s     $0##M3RSS 	/ 	/Cv...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/s   AA	Ac                       G d dt                      G d d           fd} fd} fd}t          j                            d          s  |              |              |             d S d S )	Nc                       e Zd Zd ZdS )9ExceptionTests.testSettingException.<locals>.BadExceptionc                      t          d          )Nzcan't instantiate BadException)rP   )self_s    r   r   zBExceptionTests.testSettingException.<locals>.BadException.__init__V  s    "#CDDDr   Nr   r!   r   r   BadExceptionr   U  s(        E E E E Er   r   c                       e Zd ZdS )=ExceptionTests.testSettingException.<locals>.InvalidExceptionNr   r   r    r!   r   r   InvalidExceptionr   Y          Dr   r   c                  n   dd l } 	 |                     d                               d           d S # t          $ rv}t	          j                    \  }}}|j        j        }                    |j	        d           
                    |j                            d                     Y d }~d S d }~ww xY w)Nr   rN   Expected exception
test_capi1test_exceptions.py)	_testcapiraise_exceptionri   rX   r^   exc_infotb_framef_coder5   co_name
assertTrueco_filenameendswith)r   r6   r0   tbcor   r   s        r   r   z7ExceptionTests.testSettingException.<locals>.test_capi1\  s    0)),::: 		./////  O O O"|~~S"['  \::: 7 78L M MNNNNNNNNN	Os   4 
B4A+B//B4c                     dd l } 	 |                     d                               d           d S # t          $ r}t	          j                    \  }}}|j        j        }                    |j	        d           
                    |j                            d                     |j        j        j        }                    |j	        d           Y d }~d S d }~ww xY w)Nr   r   r   r   
test_capi2)r   r   ri   rP   r^   r   r   r   r5   r   r   r   r   f_back)r   r6   r0   r   r   co2r   r   s         r   r   z7ExceptionTests.testSettingException.<locals>.test_capi2h  s    
0)),::: 		./////   < < <"|~~S"['  Z888 7 78L M MNNNk(/  l;;;;;;;;;<s   4 
C BCC c                  T    dd l }                     t          | j        d           d S )Nr   rN   )r   r\   rV   r   )r   r   r   s    r   
test_capi3z7ExceptionTests.testSettingException.<locals>.test_capi3v  s=    k9+D.3 3 3 3 3r   java)r*   r^   platform
startswith)r   r   r   r   r   r   s   `   @@r   testSettingExceptionz#ExceptionTests.testSettingExceptionP  s   
	E 	E 	E 	E 	E9 	E 	E 	E	 	 	 	 	 	 	 	
	0 
	0 
	0 
	0 
	0 
	0	0 	0 	0 	0 	0 	0	3 	3 	3 	3 	3 	3
 |&&v.. 	JLLLJLLLJLLLLL	 	r   c                 ,   	 t            |                     t           t                     |                     t	          t          d                    d           |                     t	          t          dd                    d           t          ddd          }|                     |j        d           |                     |j        d            |                     t	          |          d           t          d	ddd
          }|                     |j        d           |                     |j        d
           |                     |j        d           |                     |j        d           |                     |j	        d            |                     t	          |          d           t          d	dd d          }|                     |j        d           |                     |j        d           |                     |j        d           |                     |j        d            |                     |j	        d            |                     t	          |          d           t          dd          }|                     |j        d           |                     |j        d            |                     |j        d           |                     |j        d            |                     |j	        d            d S # t          $ r Y d S w xY w)Ni  1001messagez[Errno 1001] messager   foobarz[Errno 9] foo: 'bar'r   r   r   z[WinError 3] foo: 'bar'   z[WinError 1001] foo)WindowsErrorassertIsrC   r5   r4   errnowinerrorstrerrorfilename	filename2rL   )r   r>   s     r   test_WindowsErrorz ExceptionTests.test_WindowsError  s   $	0L MM,000S//888Sy!9!9::35 5 5 5%((AQWa(((QZ...SVV%;<<<5%++AQWa(((QZ+++QZ///QZ///Q[$///SVV%>???5$--AQWb)))QZ...QZ///QZ...Q[$///SVV%:;;;u%%AQWe,,,QZ...QZ///QZ...Q[$/////E  	 	 	DD	s   L 
LLwin32ztest specific to Windowsc                     t          d          }d}|                     t          d|z            5  |j                            |           ddd           dS # 1 swxY w Y   dS )z:Should fill in unknown error code in Windows error messagectypesl   cs@ zWindows Error 0x%xN)r   r   rC   	pythonapiPyErr_SetFromWindowsErr)r   r   codes      r   test_windows_messagez#ExceptionTests.test_windows_message  s     x((##G-AD-HII 	; 	;44T:::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;s   AAAc                 ^   t           dddift           dddift           dddift           dddift          ddddft          ddd d d d dft          d	d	d d dd
dft          dd	dd dd
dft          dd	dddft          ddddddft          dddddd dft          dd d d d d d d dft          ddd d dd d d d dft          ddd dd ddd!d"d#d$	ft          d%d d%d dd d d d d d&	ft          dddift
          d'd'd(d)d*d+d,ft          d(t          d-          d*dd+fd(t          d-          d*dd+fd(d-d*d+d,ft          d.d.d(d-d*d+d,ft          d/d/d0d1d*dd2ft          dddd3ft          dddd3fg}	 |                    t          dddd ddd d4f           n# t          $ r Y nw xY w|D ]\  }}}	  || }t          |          j                            d5          s(|                     t          |          j        d6           t'          |          }|D ]Z}t)          ||          }|                     t+          |          t+          ||                   |d7|d8|d9||                    [t,          fD ]}	t/          |	j        dz             D ]}
|	                    ||
          }|	                    |          }|D ]Q}t+          t)          ||                    }t+          ||                   }|                     ||d:|d;|           Rn#  t7          d<|d=|t8          j        >           Y xY wd S )?Nr!   args)rN   )r   )r   rN   r   )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   )rN   r   r   )rN   r   rN   )r   r   r   r   r   )rt   r   r   r   r   r   print_file_and_line)msgStrr   )r   r   r   rt   r   r   r   r   )r   )r   	linenoStr	offsetStrtextStrendLinenoStrendOffsetStrr   r   r   r   r   )	r   r   r   r   rt   r   r   r   r   )r   r   r   r   r   r   r   print_file_and_lineStr)	r   r   r   rt   r   r   r   r   r   )asciiar   rN   ordinal not in ranger   r   r   r   )r   rA   objectstartreason   )r   r   r   rN   r   )   あr   rN   ouchr   r  )r   r   r   r   end)r   r   )r   r   r   r   r   r   r   builtins.z == z, expected z	pickled "z", attribute "z
exc=z, args=)file)BaseExceptionrW   rC   rR   UnicodeErrorUnicodeEncodeErrorUnicodeDecodeError	bytearrayUnicodeTranslateErrorr   r#   appendr   rL   typer   r   r5   r   r4   r]   reprpicklerg   HIGHEST_PROTOCOLdumpsrc   printr^   stderr)r   exceptionListr0   r   expectedro   r{   checkArgNamevaluepprotocolnewgotwants                 r   testAttributeszExceptionTests.testAttributes  st    B".EFT?3H(#%J*%'"U335h"Td4 45 n("$ u6 67 +(#4 u6 67 9(u6RRT@5+z+- -. 7,++4A AB "td!dt"DB B C +%)-x"t#% %&
  G')G *.x+-^M MN  5 5 *.x"t#49 9	: 2~. ":C%#)?A AB  '9W+=+=q!"8":"Ig$6$61+AC%')?A AB   ":C%')?A AB #$<2$a) )* X!..0"H!..0eT
j
	  @0"/d "/tE EF     	 	 	D	 $1 	@ 	@Cx@CJ Aww'001ABB E$$T!WW%7DDDFF$, E EL#A|44E$$T%[[%)(<*@%A%A%&QQ%*UUH\,B,B&DE E E E ! 	@ 	@A$)!*<q*@$A$A @ @GGAx00ggajj,4 @ @L"&wsL'A'A"B"BC#'(>#?#?D ,,S$$./aa.?@ @ @ @@@	@%JSSS$$7cjIIIIII		@ 	@s   $F 
FFL#L*c                 J   t          d          t          d          t          d          fD ]}|                     |          5  |                     t          |d                     |                    d           |                     |j        dg           | 	                    t                    5  |                    d           d d d            n# 1 swxY w Y   |                     |j        dg           |                    d           |                     |j        ddg           |`|                     t          |d                     |                    d	           |                     |j        d	g           d|_        |                     |j        d           | 	                    t                    5  |                    d
           d d d            n# 1 swxY w Y   |                     |j        d           d d d            n# 1 swxY w Y   d S )NrN   r   r   ro   	__notes__zMy Note*   z	Your NotezOur Notezwill not work)r  r*   rY   r3   assertFalsehasattradd_noter5   r   r\   rX   r   ro   s     r   
test_noteszExceptionTests.test_notes5  s   ""IaLL*Q--@ 	2 	2A"" 2 2  K!8!8999

9%%%  yk:::&&y11 # #JJrNNN# # # # # # # # # # # # # # #  yk:::

;'''  y+.FGGGK  K!8!8999

:&&&  zl;;;   b111&&y11 0 0JJ///0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  b111/2 2 2 2 2 2 2 2 2 2 2 2 2 2 2	2 	2s\   A/H5CHCHCC#HG$H$G((H+G(,HH	H	c                    	 t          d          #  t          j                    d         }Y nxY wt                                          |          }|                     |t                     |                     |j        |           t          d                              |          }|                     |t                      |                     |j        |            G d dt                    } |                                |          }|                     ||           |                     |j        |           d S )Nr   r   r   c                       e Zd ZdS )5ExceptionTests.testWithTraceback.<locals>.MyExceptionNr   r!   r   r   MyExceptionr)  ^  r   r   r*  )	rF   r^   r   r  with_tracebackassertIsInstancer5   __traceback__r*   )r   r   ro   r*  s       r   testWithTracebackz ExceptionTests.testWithTracebackP  s5   	#Q--	#"BBBOO**2..a///"---qMM((,,a,,,"---	 	 	 	 	) 	 	 	 KMM((,,a---"-----    .c                     	 dt                      _        |                     d           d S # t          $ r.}|                     dt          |                     Y d }~d S d }~ww xY w)Nr   No exception raisedz!__traceback__ must be a traceback)r*   r-  ri   rX   r   r4   r%  s     r   testInvalidTracebackz#ExceptionTests.testInvalidTracebacke  s    	-()IKK% II+,,,,,  	G 	G 	GMM=s1vvFFFFFFFFF	Gs   , 
A$#AA$c                 z   |                      t          t          t                      dd           |                      t          t          t                      d           |                      t          t          t                      dd           |                      t          t          t                      d           d S )N	__cause__rN   __context__)r\   rX   setattrr*   delattrr+   s    r   testInvalidAttrszExceptionTests.testInvalidAttrsm  s    )Wikk;JJJ)Wikk;GGG)Wikk=!LLL)Wikk=IIIIIr   c                     	 t          d          #  t          j                    d         }Y nxY wt                      }||_        d |_        |                     |j        d            d S )Nr   r   )rF   r^   r   r*   r-  r5   )r   r   ro   s      r   testNoneClearsTracebackAttrz*ExceptionTests.testNoneClearsTracebackAttrs  se    	#Q--	#"BBBKK$/////r/  c                    t                      }|                     |j                   |                     |j                   t	                      }|                     |j                   |                     |j                    G d dt
                    } |            }|                     |j                   |                     |j                   d S )Nc                       e Zd ZdS )5ExceptionTests.testChainingAttrs.<locals>.MyExceptionNr   r!   r   r   r*  r=    r   r   r*  )r*   assertIsNoner5  r4  rX   rC   )r   ro   r*  s      r   testChainingAttrsz ExceptionTests.testChainingAttrs~  s    KK!-(((!+&&&KK!-(((!+&&&	 	 	 	 	' 	 	 	 KMM!-(((!+&&&&&r   c                    	 t                      # t           $ r}|}Y d }~nd }~ww xY w|                     |j                   |                     |j                   |                     |j                   t                      |_        d |_        |                     |j        t                     |                     |j                   |                     |j                   d|_        |                     |j                   d S )NF)	r*   r>  r5  r4  r"  __suppress_context__rL   r,  r   )r   r0   ro   s      r   testChainingDescriptorsz&ExceptionTests.testChainingDescriptors  s    	++ 	 	 	AAAAAA	 	!-(((!+&&&/000!amY777!+&&&.///!&/00000s    
&!&c                     |                      t          t          d            G d dt                    } |d          }|                     |j        d           d S )NrN   )r   c                       e Zd Zd ZdS )8ExceptionTests.testKeywordArgs.<locals>.DerivedExceptionc                 H    t                               |            || _        d S r   )r  r   	fancy_arg)r   rG  s     r   r   zAExceptionTests.testKeywordArgs.<locals>.DerivedException.__init__  s!    &&t,,,!*r   Nr   r!   r   r   DerivedExceptionrE    s#        + + + + +r   rH  r!  )rG  )r\   rX   r  r5   rG  )r   rH  r   s      r   testKeywordArgszExceptionTests.testKeywordArgs  s|     	)]a888	+ 	+ 	+ 	+ 	+} 	+ 	+ 	+
 r***b)))))r   c                     fd|                      t                     fd|                      t                     d S )Nc                                    S r   r!   )fs   r   rL  z/ExceptionTests.testInfiniteRecursion.<locals>.f  s    133Jr   c                  <    	               S # t           $ r Y dS w xY w)Nr   rY   gs   r   rP  z/ExceptionTests.testInfiniteRecursion.<locals>.g  s5    qss
   rrs   	 
)r\   rQ   )r   rL  rP  s    @@r   testInfiniteRecursionz$ExceptionTests.testInfiniteRecursion  sj    	 	 	 	 	.!,,,	 	 	 	 	
 	.!,,,,,r   c                    |                      t          t                               |                      t          t          d                               |                      t          t          dd                               d S )Nr   b)r   r4   r*   r+   s    r   test_strzExceptionTests.test_str  sd    I'''IcNN++,,,Ic3//0011111r   c                 6   	 t                      # t           $ r%}|                     |t                      Y d }~nd }~ww xY w|                     dt                                 |                     t
                    5  | d d d            d S # 1 swxY w Y   d S Nro   r*   r,  assertNotInlocalsr\   UnboundLocalErrorr%  s     r   test_exception_cleanup_namesz+ExceptionTests.test_exception_cleanup_names  s    	0++ 	0 	0 	0!!!Y////////	0fhh'''011 	 	A	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s"    
?:?>BBBc                 8   	 t                      # t           $ r&}|                     |t                      ~Y d }~nd }~ww xY w|                     dt                                 |                     t
                    5  | d d d            d S # 1 swxY w Y   d S rV  rW  r%  s     r   test_exception_cleanup_names2z,ExceptionTests.test_exception_cleanup_names2  s    	++ 	 	 	!!!Y///	 	fhh'''011 	 	A	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s$    
A ;A ?BBBc                     G d dt                      G d d          }fd} |            t          j                  }	  |             n# $ r
}Y d }~nd }~ww xY wd t                        |            |                                 |            t          j                  }	  |             n# $ r Y nw xY wd t                        |            |                                 |            t          j                  }	  |             n#  Y nxY wd t                        |            |                                 |            t          j                  }dD ]}	  |             #  Y  nxY wd t                        |            |                                 |            t          j                  }	 	  |             n#  t
          xY wnk# t
          $ r^}d |_        d t                        |            t          d          rt                       |                                Y d }~nd }~ww xY w |            t          j                  }	  |             n# $ r 	 	  #  xY w# $ r Y nw xY wY nw xY wd t          d          rt                        |            |                                 G d	 d
          } |            t          j                  } |            5   |             d d d            n# 1 swxY w Y   d t          d          rt                        |            |                                d S )Nc                       e Zd Zd ZdS )=ExceptionTests.testExceptionCleanupState.<locals>.MyExceptionc                     || _         d S r   objr   rc  s     r   r   zFExceptionTests.testExceptionCleanupState.<locals>.MyException.__init__      r   Nr   r!   r   r   r*  r`    #            r   r*  c                       e Zd ZdS )7ExceptionTests.testExceptionCleanupState.<locals>.MyObjNr   r!   r   r   MyObjrh    r   r   ri  c                      }            r   r!   )	local_refr*  rc  s    r   inner_raising_funczDExceptionTests.testExceptionCleanupState.<locals>.inner_raising_func  s    I+c"""r   )r   F)cpythonc                       e Zd Zd Zd ZdS )9ExceptionTests.testExceptionCleanupState.<locals>.Contextc                     | S r   r!   r+   s    r   	__enter__zCExceptionTests.testExceptionCleanupState.<locals>.Context.__enter__A      r   c                     dS )NTr!   )r   exc_type	exc_valueexc_tbs       r   __exit__zBExceptionTests.testExceptionCleanupState.<locals>.Context.__exit__C  s    tr   Nr   r   r    rq  rw  r!   r   r   Contextro  @  s2              r   ry  )r*   weakrefrefr   r>  rH   r5  r   )	r   ri  rl  wrro   iry  r*  rc  s	          @@r   testExceptionCleanupStatez(ExceptionTests.testExceptionCleanupState  s   	 	 	 	 	) 	 	 		 	 	 	 	 	 	 		# 	# 	# 	# 	# 	# egg[	     	 	 	DDDD	bdd# egg[	     	 	 	D	bdd# egg[	    	Dbdd# egg[ 	 	A""$$$$bdd# egg[	#""$$$$ %  	# 	# 	#
 !AMCLLL"$$C /// c""""""""	# egg[		     	 	 	EEE   	 U+++ 	LLLbdd#	 	 	 	 	 	 	 	
 egg[WYY 	! 	!   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!U+++ 	LLLbdd#s   
A A"A"3
B> >CC
D" "D&;
FF
G( 'G5 (	G11G5 5
I?AII?
J
 
J%JJJJJ%JJ%$J%L33L7:L7c                 f    fd}	 t            d S # t          $ r |             Y d d S d ww xY w)Nc                        d S r   r!   r  s   r   print_errorzIExceptionTests.test_exception_target_in_nested_scope.<locals>.print_errorR  s    AAAr   )	somethingr*   )r   r  ro   s     @r   %test_exception_target_in_nested_scopez4ExceptionTests.test_exception_target_in_nested_scopeO  s`    	 	 	 	 		III 	 	 	KMMMMMMMMM	s    
0
+0c                 ,   d } |            }|                      t          |          t                     |                      t          j                    d         d            |                      t          |          t                     |                      t          j                    d         d            |                      t          |          d            	 t          d          # t
          $ r  |            }|                      t          |          t                     |                      t          j                    d         t
                     |                      t          |          t                     |                      t          j                    d         t
                     |                      t          |          t
                     ~|                      t          j                    d         t
                     Y d S w xY w)Nc               3      K   	 t          d          # t           $ r9 t          j                    d         V  t          j                    d         V  Y nw xY wt          j                    d         V  d S )Ncaughtr   )rH   r^   r   r!   r   r   yield_raisez:ExceptionTests.test_generator_leaking.<locals>.yield_raise]  s      (x((( ( ( (lnnQ''''lnnQ''''''( ,..######s    A AAr   r   )r5   nextrH   r^   r   rX   )r   r  rP  s      r   test_generator_leakingz%ExceptionTests.test_generator_leakingZ  s   	$ 	$ 	$ KMMa(+++*D111a(+++*D111a$'''
	;E""" 	; 	; 	;AT!WWh///S\^^A.	:::T!WWh///S\^^A.	:::T!WWi000S\^^A.	::::::	;s   C+ +D$HHc                     d }	 t           # t           $ r  |            }t          |           Y nw xY w	 t          |           n# t          $ r Y nw xY w|                     t	          j                    d           d S )Nc               3      K   d V  d S r   r!   r!   r   r   rP  z1ExceptionTests.test_generator_leaking2.<locals>.gz  s      EEEEEr   NNN)rP   r  StopIterationr5   r^   r   r   rP  its      r   test_generator_leaking2z&ExceptionTests.test_generator_leaking2x  s    	 	 		 	 	 	BHHHHH		HHHH 	 	 	D	);<<<<<s    #22A 
AAc                    d } |            }t          |           	 ddz   n# t          $ r}|                     t          j                    d         |           |                    |          }|                     t          j                    d         |           |                     ||           Y d }~nd }~ww xY w|                     t          j                    d           d S )Nc               3   l   K   	 d V  d S # t           $ r t          j                    d         V  Y d S w xY wNrN   rZ   r^   r   r!   r   r   rP  z1ExceptionTests.test_generator_leaking3.<locals>.g  sS      ($ ( ( (lnnQ'''''''(s   
 %33rN   r   r  )r  rZ   r   r^   r   throwr5   )r   rP  r  ro   gen_excs        r   test_generator_leaking3z&ExceptionTests.test_generator_leaking3  s    	( 	( 	(
 QSSR	&aCCC  	& 	& 	&MM#,..+Q///hhqkkGMM#,..+Q///MM'1%%%%%%%%		&
 	);<<<<<s   $ 
B=BB88B=c                    d } |            }	 t           # t           $ r t          |          }Y nw xY w|                     |t                     	 t          |           nD# t          $ r7}|                     t	          j                    d         |           Y d }~nd }~ww xY w|                     t	          j                    d           d S )Nc               3   j   K   	 ddz   d S # t           $ r t          j                    d         V   w xY wNrN   r   r  r!   r   r   rP  z1ExceptionTests.test_generator_leaking4.<locals>.g  sM      !$   lnnQ''''s    '2rN   r  )rX   r  r   rZ   r^   r   r5   )r   rP  r  tpro   s        r   test_generator_leaking4z&ExceptionTests.test_generator_leaking4  s    	 	 	 QSS	O 	 	 	 bBBB	 	b+,,,	0HHHH ! 	0 	0 	0MM#,..+Q////////	0 	);<<<<<s$    22A! !
B"+-BB"c                       fd} |            }	 t           # t           $ r t          |           Y nw xY w                     t          t          |           d S )Nc               3      K                         t          j                    d         t                     d V                       t          j                    d           d S )NrN   r  )r,  r^   r   rP   r5   r+   s   r   rP  z>ExceptionTests.test_generator_doesnt_retain_old_exc.<locals>.g  sT      !!#,.."3\BBBEEES\^^-?@@@@@r   )rP   r  r\   r  r  s   `  r   $test_generator_doesnt_retain_old_excz3ExceptionTests.test_generator_doesnt_retain_old_exc  s    	A 	A 	A 	A 	A QSS	 	 	 	HHHHH	-r22222s    55c                     d fd} |             t                       |                     t          j                    d           d S )Nc               3      K   dV  d S r  r!   r!   r   r   
simple_genzIExceptionTests.test_generator_finalizing_and_exc_info.<locals>.simple_gen  s      GGGGGr   c                  f                 } 	 t           # t           $ r t          |           cY S w xY wr   )rP   r  )genr  s    r   run_genzFExceptionTests.test_generator_finalizing_and_exc_info.<locals>.run_gen  sF    *,,C!"" ! ! !Cyy   !s    00r  )r   r5   r^   r   )r   r  r  s     @r   &test_generator_finalizing_and_exc_infoz5ExceptionTests.test_generator_finalizing_and_exc_info  sd    	 	 		! 	! 	! 	! 	! 				);<<<<<r   c                 <    G d dt                      G d d          }fd} |            t          j                  } |            }t          |            ||           d x}t	                        |            |                                d S )Nc                       e Zd Zd ZdS )FExceptionTests._check_generator_cleanup_exc_state.<locals>.MyExceptionc                     || _         d S r   rb  rd  s     r   r   zOExceptionTests._check_generator_cleanup_exc_state.<locals>.MyException.__init__  re  r   Nr   r!   r   r   r*  r    rf  r   r*  c                       e Zd ZdS )@ExceptionTests._check_generator_cleanup_exc_state.<locals>.MyObjNr   r!   r   r   ri  r    r   r   ri  c               3   @   K   	             #  $ r d V  Y d S w xY wr   r!   )r*  rc  s   r   raising_genzFExceptionTests._check_generator_cleanup_exc_state.<locals>.raising_gen  sF      !k#&&&   s    	)r*   rz  r{  r  r   r>  )r   testfuncri  r  r|  rP  r*  rc  s         @@r   "_check_generator_cleanup_exc_statez1ExceptionTests._check_generator_cleanup_exc_state  s    	 	 	 	 	) 	 	 		 	 	 	 	 	 	 		 	 	 	 	 	 egg[KMMQCbdd#r   c                 6    d }|                      |           d S )Nc                 l    	 |                      t                                 d S # t          $ r Y d S w xY wr   )r  rP   rO  s    r   do_throwzGExceptionTests.test_generator_throw_cleanup_exc_state.<locals>.do_throw  sE    '''''   s   !% 
33r  )r   r  s     r   &test_generator_throw_cleanup_exc_statez5ExceptionTests.test_generator_throw_cleanup_exc_state  s-    	 	 	
 	//99999r   c                 6    d }|                      |           d S )Nc                 .    |                                   d S r   )r`   rO  s    r   do_closezGExceptionTests.test_generator_close_cleanup_exc_state.<locals>.do_close  s    GGIIIIIr   r  )r   r  s     r   &test_generator_close_cleanup_exc_statez5ExceptionTests.test_generator_close_cleanup_exc_state  s+    	 	 	//99999r   c                 6    d }|                      |           d S )Nc                 
    d } d S r   r!   rO  s    r   do_delzCExceptionTests.test_generator_del_cleanup_exc_state.<locals>.do_del  s    AAAr   r  )r   r  s     r   $test_generator_del_cleanup_exc_statez3ExceptionTests.test_generator_del_cleanup_exc_state  s+    	 	 	//77777r   c                 <      fd}                      |           d S )Nc                 t    	 t          |                                d           d S # t          $ r Y d S w xY wNz should have raised StopIteration)r  ri   r  rP  r   s    r   do_nextzEExceptionTests.test_generator_next_cleanup_exc_state.<locals>.do_next  sR    >Q 		<===== !   s   ) 
77r  )r   r  s   ` r   %test_generator_next_cleanup_exc_statez4ExceptionTests.test_generator_next_cleanup_exc_state  8    	> 	> 	> 	> 	> 	//88888r   c                 <      fd}                      |           d S )Nc                     	 |                      d                                d           d S # t          $ r Y d S w xY wr  )sendri   r  r  s    r   do_sendzEExceptionTests.test_generator_send_cleanup_exc_state.<locals>.do_send  sV    >t 		<===== !   s   / 
==r  )r   r  s   ` r   %test_generator_send_cleanup_exc_statez4ExceptionTests.test_generator_send_cleanup_exc_state  r  r   c                      G fdd          }d	 t           |                      #  Y nxY wt                       |                     d           d S )Nc                       e Zd Z fdZdS )*ExceptionTests.test_3114.<locals>.MyObjectc                 .    t          j                    d S r   )r^   r   r%  s    r   __del__z2ExceptionTests.test_3114.<locals>.MyObject.__del__  s    LNNr   Nr   r   r    r  r  s   r   MyObjectr    s.        # # # # # # #r   r  r!   r  )r*   r   r5   )r   r  ro   s     @r   	test_3114zExceptionTests.test_3114  s    	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	HHJJ'''	D./////s   + /c                     G d dt                     } G d dt                     } G d dt                     }	 	 |# |$ r}|}	 |# |$ r}|}	 |# |$ r}|}	|                     ||           |                     ||           |                     |	|           |                     |j                   |                     |j        |           |                     |	j        |           |d }~ww xY wd }~ww xY wd }~ww xY w# |$ r}
|
}Y d }
~
nd }
~
ww xY w|                     ||           |                     |j        |	           |                     |	j        |           |                     |j                   d S )Nc                       e Zd ZdS )HExceptionTests.test_raise_does_not_create_context_chain_cycle.<locals>.ANr   r!   r   r   Ar    r   r   r  c                       e Zd ZdS )HExceptionTests.test_raise_does_not_create_context_chain_cycle.<locals>.BNr   r!   r   r   Br     r   r   r  c                       e Zd ZdS )HExceptionTests.test_raise_does_not_create_context_chain_cycle.<locals>.CNr   r!   r   r   Cr  "  r   r   r  )r*   r,  r>  r5  r   )r   r  r  r  a_r   b_rS  c_cro   r0   s               r   .test_raise_does_not_create_context_chain_cyclez=ExceptionTests.test_raise_does_not_create_context_chain_cycle  s&   	 	 	 	 		 	 	 		 	 	 	 		 	 	 		 	 	 	 		 	 	 		        G      A
       --a333--a333--a333))!-888amQ777amQ777 	 	 "  	 	 	CCCCCC	 	c1amQ'''amQ'''!-(((((sj   > DC=AC:C5AC2BC--C22C55C::C==DD D
DDc                    d }	  |             n# t           $ r}|}Y d }~nd }~ww xY w|                     |t                     |                     |j        t                     |                     |j        j        |j                   d S )Nc                  r    	 t          d          # t           $ r} | | _        t          d          d } ~ ww xY wNrN   r   )rY   r5  rX   exs    r   cyclezBExceptionTests.test_no_hang_on_context_chain_cycle1.<locals>.cycleH  sE    # mm# # # #!#ll"#s    
616)r*   r,  rX   r5  rY   r   )r   r  ro   r0   s       r   $test_no_hang_on_context_chain_cycle1z3ExceptionTests.test_no_hang_on_context_chain_cycle1E  s    	# 	# 	#	EGGGG 	 	 	CCCCCC	 	c9---coz:::co13?CCCCCs   
 
&!&zSee issue 44895c                 @    G d dt                     } G d dt                     } G d dt                     }|                     |          5 }	  |            # |$ rD}|}	  |            # |$ r*}|}	  |            # |$ r}	|	}
|
|_        |
d }	~	ww xY wd }~ww xY wd }~ww xY w# 1 swxY w Y   |                     |j        |
           |                     |
j        |           |                     |j        |           |                     |j        |
           d S )Nc                       e Zd ZdS )>ExceptionTests.test_no_hang_on_context_chain_cycle2.<locals>.ANr   r!   r   r   r  r  \  r   r   r  c                       e Zd ZdS )>ExceptionTests.test_no_hang_on_context_chain_cycle2.<locals>.BNr   r!   r   r   r  r  ^  r   r   r  c                       e Zd ZdS )>ExceptionTests.test_no_hang_on_context_chain_cycle2.<locals>.CNr   r!   r   r   r  r  `  r   r   r  r*   r\   r5  r   r   )r   r  r  r  r   _ar   _brS  _cr  s              r   $test_no_hang_on_context_chain_cycle2z3ExceptionTests.test_no_hang_on_context_chain_cycle2X  s   	 	 	 	 		 	 	 		 	 	 	 		 	 	 		 	 	 	 		 	 	 	 q!! 	 R acc	      	 !##I      A acc	      () 	 	 	  	  	  	  	  	  	  	   	blA&&&amQ'''amQ'''amQ'''''sl   B'
AB$ B#
A--B2B5
A??B	B	B	BBBB$$B''B+.B+c                 @    G d dt                     } G d dt                     } G d dt                     } G d dt                     } G d	 d
t                     }|                     |          5 }	  |            # |$ rh}|}	  |            # |$ rN}	|	}
	  |            # |$ r4}|}||_        	  |            # |$ r}|} |            }|d }~ww xY wd }~ww xY wd }	~	ww xY wd }~ww xY w# 1 swxY w Y   |                     |j        |           |                     |j        |           |                     |j        |           |                     |j        |
           |                     |
j        |           |                     |j        |           d S )Nc                       e Zd ZdS )>ExceptionTests.test_no_hang_on_context_chain_cycle3.<locals>.ANr   r!   r   r   r  r    r   r   r  c                       e Zd ZdS )>ExceptionTests.test_no_hang_on_context_chain_cycle3.<locals>.BNr   r!   r   r   r  r    r   r   r  c                       e Zd ZdS )>ExceptionTests.test_no_hang_on_context_chain_cycle3.<locals>.CNr   r!   r   r   r  r    r   r   r  c                       e Zd ZdS )>ExceptionTests.test_no_hang_on_context_chain_cycle3.<locals>.DNr   r!   r   r   Dr    r   r   r  c                       e Zd ZdS )>ExceptionTests.test_no_hang_on_context_chain_cycle3.<locals>.ENr   r!   r   r   Er    r   r   r   r  )r   r  r  r  r  r   r   r  r   r  rS  r  r  _ddro   s                   r   $test_no_hang_on_context_chain_cycle3z3ExceptionTests.test_no_hang_on_context_chain_cycle3}  s   	 	 	 	 		 	 	 		 	 	 	 		 	 	 		 	 	 	 		 	 	 		 	 	 	 		 	 	 		 	 	 	 		 	 	 	 q!! 	$R$acc	 $ $ $$!##I $ $ $A
$acc	 $ $ $()$"#!##I  $ $ $ "A !A"#G$$	$	$	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$* 	blA&&&amQ'''amQ'''amQ'''amQ'''amQ'''''s   5C17
BC.C)	
BC&C!
B%%C	*	C	4
B>>CCCC	C	C!!C&&C))C..C11C58C5c                     	 	 t          d          }|# t          d          }|xY w# t          $ r}|}Y d }~nd }~ww xY w|                     ||           |                     |j        |           d S r  )rX   rY   r*   r   r5  )r   tevero   r0   s        r   ,test_context_of_exception_in_try_and_finallyz;ExceptionTests.test_context_of_exception_in_try_and_finally  s    	q\\]] 	 	 	CCCCCC	 	c2cor*****s    &) 
?:?c                 V   	 	 t          d          }|#  t          d          }|xY w# t          d          }|xY w# t          $ r}|}Y d }~nd }~ww xY w|                     ||           |                     |j        |           |                     |j        j        |           d S )NrN   r   r   )rX   rY   rC   r*   r   r5  )r   r  r  oero   r0   s         r   /test_context_of_exception_in_except_and_finallyz>ExceptionTests.test_context_of_exception_in_except_and_finally  s    	q\\]]QZZ 	 	 	CCCCCC	 	c2cor***co1266666s%    '* <? 
A	AAc                    	 	 	 t          d          }|#  Y nxY w	 t          d          }|# t          d          }|xY w# t          $ r}|}Y d }~nd }~ww xY w|                     ||           |                     |j        |           d S r  )rY   rC   r*   r   r5  )r   r  r	  ro   r0   s        r   -test_context_of_exception_in_else_and_finallyz<ExceptionTests.test_context_of_exception_in_else_and_finally  s    		  ]]	
 QZZ QZZ 	 	 	CCCCCC	 	c2cor*****s.   . . A A  A 
AAAc                    t          ddddd          }|                     t          |          d           d|_        |                     t          |          d           d|_        d	|_        |                     t          |          d
           d|_        |                     t          |          d           d|_        |                     t          |          d           t          ddddd          }|                     t          |          d           d|_        |                     t          |          d           d|_        d	|_        |                     t          |          d           d|_        |                     t          |          d           d|_        |                     t          |          d           t          dddd          }|                     t          |          d           d|_        |                     t          |          d           d|_        d	|_        |                     t          |          d           d|_        |                     t          |          d           d S )Nr   xxxxxrN   r   r   z8'baz' codec can't encode characters in position 1-4: foor   z<'baz' codec can't encode character '\x78' in position 1: fool   ESh
MQ)EzJ'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: 965230951443685724997s   xxxxxz3'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  r5   r4   r  r   rA   r   r	  r  )r   us     r   test_unicode_change_attributesz-ExceptionTests.test_unicode_change_attributes  s?    ugq!U;;Q![\\\Q!`aaa'Q!mnnn
Q!noooQ!qrrruh1e<<Q!VWWWQ!XYYY'Q!hiii
Q!ijjjQ!lmmm!&!Q66Q!RSSSQ!WXXX'Q!deeeQ!ghhhhhr   c                     t           t          t          f}|D ]8}|                     t	          |                    |                    d           9d S )N )r  r	  r  r5   r4   __new__)r   klassesklasss      r   test_unicode_errors_no_objectz,ExceptionTests.test_unicode_errors_no_object  sV    $&8:OO 	< 	<ESu!5!566;;;;	< 	<r   c                     G d dt                     } G d dt          |          }t                      5 }	 t                      # |$ r}|                     d           Y d }~n*d }~wt          $ r Y n |                     d           Y nxY wd d d            n# 1 swxY w Y   fd             \  }}}|                     |t          t          |                     |                     d	t          |                     d S )
Nc                       e Zd Zd ZdS )/ExceptionTests.test_badisinstance.<locals>.Metac                     t                      r   rN  )clssubclasss     r   __subclasscheck__zAExceptionTests.test_badisinstance.<locals>.Meta.__subclasscheck__  s     ll"r   N)r   r   r    r  r!   r   r   Metar    s#        # # # # #r   r  c                       e Zd ZdS )6ExceptionTests.test_badisinstance.<locals>.MyExceptionNr   r!   r   r   r*  r!    r   r   r*  )	metaclasszShould have raised KeyErrorz%exception should not be a MyExceptionc                  `    	               S # t           $ r t          j                    cY S w xY wr   )rQ   r^   r   rO  s   r   rP  z,ExceptionTests.test_badisinstance.<locals>.g  s@    &qss
! & & &|~~%%%&s   	 --z maximum recursion depth exceeded)	r  r*   r   rH   ri   r,  rQ   r   r4   )r   r  r*  r  ro   vr   rP  s          @r   test_badisinstancez!ExceptionTests.test_badisinstance	  s   	# 	# 	# 	# 	#4 	# 	# 	#	 	 	 	 	)t 	 	 	 	  
	9&	9jj  C C C		ABBBBBBBB   9		788888
	9 
	9 
	9 
	9 
	9 
	9 
	9 
	9 
	9 
	9 
	9 
	9 
	9 
	9 
	9	& 	& 	& 	& 	&
 1331baa9998#a&&AAAAAs@   BABA'"B'B4B6BBB!$B!c                 F    d } |             t          j                     d S )Nc                  T    t                      } t          d          D ]	}| j        } 
d S )Ni@B )r   rg   __dir__)or   s     r   r   z3ExceptionTests.test_trashcan_recursion.<locals>.foo.  s7    A9%%   I r   )r   r   )r   r   s     r   test_trashcan_recursionz&ExceptionTests.test_trashcan_recursion)  s3    
	 	 	 	r   c                     dt           z  }t          j        dd|          \  }}}|                     |d           |                     d|           |                     d|           |                     d|           d S )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-crN   s   RecursionErrors   ResourceWarning   Done.)__file__r	   assert_python_failurer5   r   r   r   rcoutr6   s        r   $test_recursion_normalizing_exceptionz3ExceptionTests.test_recursion_normalizing_exception8  s    (P Q(R %:5$MMCQ'---(#...h$$$$$r   c                     d}t          j        d|          \  }}}|                     |d           |                     d|           |                     d|           d S )Nzif 1:
            import _testcapi
            try:
                raise _testcapi.RecursingInfinitelyError
            finally:
                print('Done.')
        r-  rN   sO   RecursionError: maximum recursion depth exceeded while normalizing an exceptionr.  )r	   r0  r5   r   r1  s        r   -test_recursion_normalizing_infinite_exceptionz<ExceptionTests.test_recursion_normalizing_infinite_exceptions  sq    
 %:4FFCQ 89<	> 	> 	>h$$$$$r   c                    d }fdfdfdt          j                    }	  |d           fD ]a}|                     |          5  	  |             |                     d           n# t          $ r Y nw xY wd d d            n# 1 swxY w Y   b	 t          j        |           d S # t          j        |           w xY w)Nc                     d}	 	 t          j        |           n# t          $ r |dz  }Y nw xY w,t          j        || z              d S r  )r^   setrecursionlimitrQ   )ndepths     r   set_relative_recursion_limitzUExceptionTests.test_recursion_in_except_handler.<locals>.set_relative_recursion_limit  ss    E)%000  &   QJEEE !%'*****s    ,,c                  8    	 ddz   d S #                 Y d S xY wr  r!   )recurse_in_excepts   r   r>  zJExceptionTests.test_recursion_in_except_handler.<locals>.recurse_in_except  s6    $!$!!######s   
 c                  8    	 ddz   n#  Y nxY w               d S r  r!   )recurse_after_excepts   r   r@  zMExceptionTests.test_recursion_in_except_handler.<locals>.recurse_after_except  s6    !  """""s   	 c                  B    	                d S #                 Y d S xY wr   r!   )recurse_in_body_and_excepts   r   rB  zSExceptionTests.test_recursion_in_except_handler.<locals>.recurse_in_body_and_except  s>    -**,,,,,-**,,,,,,s   
 rG   )funcz#Should have raised a RecursionError)r^   getrecursionlimitr3   ri   rQ   r9  )r   r<  recursionlimitrC  r@  rB  r>  s       @@@r    test_recursion_in_except_handlerz/ExceptionTests.test_recursion_in_except_handler  s   		+ 		+ 		+	$ 	$ 	$ 	$ 	$	# 	# 	# 	# 	#	- 	- 	- 	- 	- .00	2((,,,*,@B\] I I\\t\,, I II 		"GHHHH *   I I I I I I I I I I I I I I II !.11111C!.1111sS   (B3 B
A4B4
B>B BBB3 B	B3 B	B3 3C	c                     d}t                      5  t          j        d|          \  }}}|                     d|           d d d            d S # 1 swxY w Y   d S )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-     MemoryError)r
   r	   r0  r   r1  s        r   )test_recursion_normalizing_with_no_memoryz8ExceptionTests.test_recursion_normalizing_with_no_memory  s     !"" 	/ 	/(>tTJJLBSMM.#...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/s   0AAAc                      dd l ddlm  fd} |            } |            }                     ||           d S )Nr   raise_memoryerrorc                      	                                    d           n# t          $ r} | j        }Y d } ~ nd } ~ ww xY w                    |          S )Nz Should have raised a MemoryError)ri   rK   r-  	format_tb)ro   r   rL  r   	tracebacks     r   raiseMemErrorz6ExceptionTests.test_MemoryError.<locals>.raiseMemError  sw    >!!### 		<====  % % %_% &&r***s   
# 
>9>)rO  r   rL  r5   )r   rP  tb1tb2rL  rO  s   `   @@r   test_MemoryErrorzExceptionTests.test_MemoryError  s|     	//////	+ 	+ 	+ 	+ 	+ 	+ 	+ moomooc"""""r   c                 ,   dd l }d}d}|                     t          |j        d           |                    d          }|                     t          |          t
                     |                     t          |t                               | 	                    |j
                   |                    d|          }|                     |j
        |           |                    d|          }|                     t          ||                      G d	 d
t                    }|                    d|||f          }|                     t          ||                     |                     t          ||                     |                     |j
        |           |                    dd|ddi          }	|                     t          |	|                     |                     |	j        d           |                     |	j
        d           d S )Nr   zThis is a test docstring.zThis is another test docstring.error1z_testcapi.error1z_testcapi.error2z_testcapi.error3)basec                       e Zd ZdS )1ExceptionTests.test_exception_with_doc.<locals>.CNr   r!   r   r   r  rX    r   r   r  z_testcapi.error4z_testcapi.error5r  r   rN   )r   r\   rV   make_exception_with_docr   r  r   
issubclassr*   r>  __doc__r5   r   r   )
r   r   doc2doc4rU  error2error3r  error4error5s
             r   test_exception_with_docz&ExceptionTests.test_exception_with_doc  s"   *0+y'H"	$ 	$ 	$ 223EFFd6llD)))
6955666&.))) 223EtLL... 223E8> 3 @ @
6622333	 	 	 	 	 	 	 	223Et4:A;@ @
6622333
61--...... 223Er39C8E E
66223331%%%,,,,,r   c                 H   ddl m  G d d          d fd}	  |             |                     d           n5# t          $ r(}|                                  d            Y d }~nd }~ww xY wt                       |                                  d            d S )Nr   rK  c                       e Zd ZdS )3ExceptionTests.test_memory_error_cleanup.<locals>.CNr   r!   r   r   r  re    r   r   r  c                  X                 } t          j        |                         d S r   rz  r{  )r  r  rL  r|  s    r   innerz7ExceptionTests.test_memory_error_cleanup.<locals>.inner  s0    AQBr   zMemoryError not raised)r   rL  ri   rK   assertNotEqualr   r5   )r   rh  ro   r  rL  r|  s      @@@r   test_memory_error_cleanupz(ExceptionTests.test_memory_error_cleanup  s
    	0/////	 	 	 	 	 	 	 		  	  	  	  	  	  	 	0EGGG II.////  	, 	, 	,d++++++++	, 	t$$$$$s   
A 
A3A..A3c                 <    G d d          d fd	               |                      d           n5# t          $ r(}|                                  d            Y d }~nd }~ww xY wt                       |                                  d            d S )Nc                       e Zd ZdS )6ExceptionTests.test_recursion_error_cleanup.<locals>.CNr   r!   r   r   r  rm     r   r   r  c                  X                 } t          j        |                         d S r   rg  )r  r  rh  r|  s    r   rh  z:ExceptionTests.test_recursion_error_cleanup.<locals>.inner#  s*    AQBEGGGGGr   zRecursionError not raised)ri   rQ   ri  r   r5   )r   ro   r  rh  r|  s     @@@r   test_recursion_error_cleanupz+ExceptionTests.test_recursion_error_cleanup  s    	 	 	 	 	 	 	 		 	 	 	 	 	 		3EGGG II12222  	, 	, 	,d++++++++	, 	t$$$$$s   
; 
A-A((A-c                     |                      t                    5 }t          j        t                     d d d            n# 1 swxY w Y   |                     |j        j        t          j        |j                   d S r   )	r\   rC   oslistdirr/  r5   r   r   ENOTDIR)r   r   s     r   test_errno_ENOTDIRz!ExceptionTests.test_errno_ENOTDIR2  s    w'' 	!2Jx   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!+U]BLIIIIIs   AAAc                 2    G d d          } |            }t          j                    5 }~t                       |                     |j        j        |j                   |                     |j        j                   d d d            d S # 1 swxY w Y   d S )Nc                       e Zd Zd ZdS )1ExceptionTests.test_unraisable.<locals>.BrokenDelc                 $    t          d          }|)Nzdel is brokenrN  r   r0   s     r   r  z9ExceptionTests.test_unraisable.<locals>.BrokenDel.__del__;  s     11	r   Nr  r!   r   r   	BrokenDelrw  :  s#            r   rz  )	r   catch_unraisable_exceptionr   r5   
unraisabler   r  assertIsNotNoneexc_traceback)r   rz  rc  r   s       r   test_unraisablezExceptionTests.test_unraisable8  s    	 	 	 	 	 	 	 	 ikk/11 	>RLLLR]193DEEE  !<===	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>s   ABBBc           	         t           t          fD ]G}|                     |          5  	  |d          }|# |$ rH t                      5 }t	          j        t	          j                      d d d            n# 1 swxY w Y   Y nw xY w|                                }|                     d|           |                     d|           |                     |j	        |           |t          u r|                     d|           n|                     d|           | 
                    |                    d                     d d d            n# 1 swxY w Y   Id S )Nztest messager   z	raise excz<exception str() failed>r   )rY   r'   r3   r   r^   __excepthook__r   getvaluer   r   r   r   )r   rt  r0   r  reports        r   test_unhandledzExceptionTests.test_unhandledH  s   #%78 	7 	7Hh'' 7 7<"(>22CI < < <(** <f*CLNN;;< < < < < < < < < < < < < < <<  **2F;;;k6222h/888111MM"<fEEEEMM.&999 5 5666!7 7 7 7 7 7 7 7 7 7 7 7 7 7 7	7 	7sQ   E6B	 A5	)B5A99B<A9=B EBB<EE	E	c                     d}t          dd          D ]J}t          j        d||z            \  }}}|                     |d           |                     d|           Kd S )Nzif 1:
            import _testcapi
            class C(): pass
            _testcapi.set_nomemory(0, %d)
            C()
        rN   r   r-  )rN   x   rH  )rg   r	   r0  r   )r   r   r}  r2  r3  r6   s         r   "test_memory_error_in_PyErr_PrintExz1ExceptionTests.test_memory_error_in_PyErr_PrintEx]  ss     q" 	/ 	/A(>tTAXNNLBSMM"h'''MM.#....	/ 	/r   c                 6    G d dt                      G d dt                     fd} |            }|                    d            |                               5  |                                            d d d            d S # 1 swxY w Y   d S )Nc                       e Zd ZdS )BExceptionTests.test_yield_in_nested_try_excepts.<locals>.MainErrorNr   r!   r   r   	MainErrorr  p  r   r   r  c                       e Zd ZdS )AExceptionTests.test_yield_in_nested_try_excepts.<locals>.SubErrorNr   r!   r   r   SubErrorr  s  r   r   r  c               3   T   K   	               #  $ r 	 d V  n# $ r Y nw xY w w xY wr   r!   )r  r  s   r   mainz=ExceptionTests.test_yield_in_nested_try_excepts.<locals>.mainv  sf      ikk!   EEEE   Ds    
 ''"'"')r*   r  r\   r  )r   r  coror  r  s      @@r    test_yield_in_nested_try_exceptsz/ExceptionTests.test_yield_in_nested_try_exceptsn  s"   	 	 	 	 		 	 	 		 	 	 	 	y 	 	 		 	 	 	 	 	 tvv		$y)) 	# 	#JJxxzz"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#s   #BBBc                       fd} |            }	 t           # t           $ r&                      t          |          d           Y nw xY w                     t          |          d           d S )Nc               3      K   	 t           # t           $ r dV  Y nw xY w                     t          j                    d           dV  d S )NrN   r  r   )rY   r5   r^   r   r+   s   r   rP  z?ExceptionTests.test_generator_doesnt_retain_old_exc2.<locals>.g  sd           S\^^-?@@@GGGGGs    rN   r   )rF   r5   r  )r   rP  r  s   `  r   %test_generator_doesnt_retain_old_exc2z4ExceptionTests.test_generator_doesnt_retain_old_exc2  s    	 	 	 	 	 acc	+ 	+ 	+ 	+T#YY*****	+cA&&&&&s    -A	A	c                     d }|                      t                    5   |            }	 ddz   n%#  t          |           t          |           Y nxY wd d d            d S # 1 swxY w Y   d S )Nc               3      K   dV   r  r!   r!   r   r   rP  z1ExceptionTests.test_raise_in_generator.<locals>.g  s      GGGr   rN   r   )r\   rZ   r  )r   rP  r}  s      r   test_raise_in_generatorz&ExceptionTests.test_raise_in_generator  s    	 	 	
 011 	 	A!QQ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s%   A"0A" AA""A&)A&z Won't work if __debug__ is Falsec                     t           a	 b|                     d           d S # t          $ rJ}b|                     |t                     |                     t          |          d           Y d }~d S d }~ww xY w)Nr   hello)rX   AssertionErrorri   r  r,  r5   r4   r%  s     r   test_assert_shadowingz$ExceptionTests.test_assert_shadowing  s    
 #	, II*+++++  	. 	. 	.!!!^444SVVW---------	.s   
A5?A00A5c                     G d dt                     }	 t           # t           $ r}|}Y d }~nd }~ww xY w	 |# t          $ r Y nw xY wt          d          D ]/}	 t           # t           $ r
}Y d }~nd }~ww xY wt                       0d S )Nc                       e Zd ZdS )BExceptionTests.test_memory_error_subclasses.<locals>.TestExceptionNr   r!   r   r   TestExceptionr    r   r   r  rG   )rK   r*   rg   r   )r   r  r0   inst_s        r   test_memory_error_subclassesz+ExceptionTests.test_memory_error_subclasses  s    	 	 	 	 	K 	 	 		 	 	 	DDDDDD		 	 	 	D	 r 	 	A!!    LLLL	 	s1    
2-28 
AAA!!
A50A5)NNr?   )Sr   r   r    r9   rp   r|   r   r   r   r   unittestskipIfr   r^   maxsizer   requires_resource
bigmemtestr   r   r   r   
skipUnlessr   r   r  r&  r.  r2  r8  r:  r?  rB  rI  r   rQ  rT  r[  r]  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  skipr  r  r  r
  r  r  r  r%  r*  r4  r6  rF  rI  rS  rb  rj  ro  rt  r  r  r  r  r  r  r  r  r!   r   r   r.   r.   ,   s       4 4 4RC RC RCh? ? ?.'Q 'Q 'QR7 7 7 7"2 2 2b) b) b)H X_W+-XYYWu%%W5999/ / :9 &% ZY/
 - - \-^%0 %0 %0N X035 5; ;5 5;B@ B@ B@H2 2 26. . .*- - -J J J	0 	0 	0' ' ' 1 1 1$* * * 
- 
- Z
-2 2 2	 	 		 	 	w w wr  ; ; ;<= = == = =&= = =6
3 
3 
3= = =  2: : :: : :
8 8 8
9 9 99 9 90 0 0&) &) &)PD D D& X]$%%"( "( &%"(H-( -( -(^+ + +7 7 7$+ + +$#i #i #iJ< < < B B ZB> Wu%%  &% \ 8% 8% \8%t % % \%$,2 ,2 ,2^ / / \/* # # \#$ %- %- \%-N % % \%, % % Z%(J J J> > > 7 7 7* / / \/ # # #.' ' '$   X$FGG, , HG,    r   r.   c                   P    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd ZdS )NameErrorTestsc                 |    	 t            d S # t          $ r&}|                     d|j                   Y d }~d S d }~ww xY w)Nbluch)r  rL   r5   namery  s     r   test_name_error_has_namez'NameErrorTests.test_name_error_has_name  sY    	0EEE 	0 	0 	0Wch/////////	0s    
;6;c                    d }d }d }d }d }d }|df|df|d	f|d
f|df|dffD ]\  }}d }		  |             na# t           $ rT}
t          j                    5 }	t          j        t          j                      d d d            n# 1 swxY w Y   Y d }
~
nd }
~
ww xY w|                     ||	                                           d S )Nc                  B    d x} x}x}}d }t          t                     d S r   r  r  )noise
more_noiser   bcblechs        r   Substitutionz@NameErrorTests.test_name_error_suggestions.<locals>.Substitution  s*    *..E.J.RE%LLLLLr   c                  B    d x} x}x}}d }t          t                     d S r   r  )r  r  r   r  blchs        r   Eliminationz?NameErrorTests.test_name_error_suggestions.<locals>.Elimination  s*    *..E.J.RD%LLLLLr   c                  B    d x} x}x}}d }t          t                     d S r   r  )r  r  r   r  bluchins        r   Additionz<NameErrorTests.test_name_error_suggestions.<locals>.Addition  s*    *..E.J.RG%LLLLLr   c                  6    d } d }t          t                     d S r   r  )blachblucs     r   SubstitutionOverEliminationzONameErrorTests.test_name_error_suggestions.<locals>.SubstitutionOverElimination  s    ED%LLLLLr   c                  6    d } d }t          t                     d S r   r  )r  bluchis     r   SubstitutionOverAdditionzLNameErrorTests.test_name_error_suggestions.<locals>.SubstitutionOverAddition  s    EF%LLLLLr   c                  6    d } d }t          t                     d S r   r  )bluchar  s     r   EliminationOverAdditionzKNameErrorTests.test_name_error_suggestions.<locals>.EliminationOverAddition  s    FD%LLLLLr   'blech'?'blch'?
'bluchin'?z	'blucha'?'blach'?rL   r   r   r^   r  r   r   r  )r   r  r  r  r  r  r  rC  
suggestionr6   r0   s              r   test_name_error_suggestionsz*NameErrorTests.test_name_error_suggestions  s   	 	 	
	 	 	
	 	 	
	 	 	
	 	 	
	 	 	
 #/
!;!,i 8!)< 8!8+ F!<j I!9: F!H 	6 	6D* C8 8 8 8,.. 8#&778 8 8 8 8 8 8 8 8 8 8 8 8 8 88 MM*cllnn5555	6 	6s9   
:
BB B7BBB
BBBc                 6   d }	  |             na# t           $ rT}t          j                    5 }t          j        t          j                      d d d            n# 1 swxY w Y   Y d }~nd }~ww xY w|                     d|                                           d S )Nc                  .    t          t                     d S r   )r  global_for_suggestior!   r   r   rC  zENameErrorTests.test_name_error_suggestions_from_globals.<locals>.func  s    &'''''r   z'global_for_suggestions'?r  r   rC  r0   r6   s       r   (test_name_error_suggestions_from_globalsz7NameErrorTests.test_name_error_suggestions_from_globals
  s    	( 	( 	(	4DFFFF 	4 	4 	4(** 4c"CLNN334 4 4 4 4 4 4 4 4 4 4 4 4 4 4	4 	13<<>>BBBBB7   
 
A.A) AA)A	A) A	!A))A.c                 6   d }	  |             na# t           $ rT}t          j                    5 }t          j        t          j                      d d d            n# 1 swxY w Y   Y d }~nd }~ww xY w|                     d|                                           d S )Nc                  .    t          t                     d S r   )r  ZeroDivisionErrrrrr!   r   r   rC  zFNameErrorTests.test_name_error_suggestions_from_builtins.<locals>.func  s    $%%%%%r   z'ZeroDivisionError'?r  r  s       r   )test_name_error_suggestions_from_builtinsz8NameErrorTests.test_name_error_suggestions_from_builtins  s    	& 	& 	&	4DFFFF 	4 	4 	4(** 4c"CLNN334 4 4 4 4 4 4 4 4 4 4 4 4 4 4	4 	,cllnn=====r  c                 6   d }	  |             na# t           $ rT}t          j                    5 }t          j        t          j                      d d d            n# 1 swxY w Y   Y d }~nd }~ww xY w|                     d|                                           d S )Nc                  2    d } t          t                     d S r   )r  somethingverywronghe)somethingverywronghehehehehehes    r   rL  zSNameErrorTests.test_name_error_suggestions_do_not_trigger_for_long_names.<locals>.f  s    -1*&'''''r   somethingverywrongheherL   r   r   r^   r  r   rX  r  r   rL  r0   r6   s       r   9test_name_error_suggestions_do_not_trigger_for_long_nameszHNameErrorTests.test_name_error_suggestions_do_not_trigger_for_long_names  s    	( 	( 	(	4ACCCC 	4 	4 	4(** 4c"CLNN334 4 4 4 4 4 4 4 4 4 4 4 4 4 4	4 	13<<>>BBBBBr  c                 \   d x}x}x}x}}|                      d          5  	 t           na# t          $ rT}t          j                    5 }t          j        t          j                      d d d            n# 1 swxY w Y   Y d }~nd }~ww xY w|                     d|	                                           |                     d|	                                           |                     d|	                                           |                     d|	                                           |                     d|	                                           |                     d|	                                           d d d            n# 1 swxY w Y   |                      d	          5  	 t           na# t          $ rT}t          j                    5 }t          j        t          j                      d d d            n# 1 swxY w Y   Y d }~nd }~ww xY w|                     d|	                                           |                     d|	                                           |                     d|	                                           |                     d|	                                           |                     d|	                                           |                     d|	                                           d d d            n# 1 swxY w Y   |                      d
          5  	 t           na# t          $ rT}t          j                    5 }t          j        t          j                      d d d            n# 1 swxY w Y   Y d }~nd }~ww xY w|                     d|	                                           |                     d|	                                           |                     d|	                                           |                     d|	                                           |                     d|	                                           |                     d|	                                           d d d            n# 1 swxY w Y   |                      d          5  	 t           na# t          $ rT}t          j                    5 }t          j        t          j                      d d d            n# 1 swxY w Y   Y d }~nd }~ww xY w|                     d|	                                           |                     d|	                                           |                     d|	                                           |                     d|	                                           |                     d|	                                           |                     d|	                                           d d d            d S # 1 swxY w Y   d S )NrS  r  you meanvvvmom'id''w''pytho'r$  mpy)r3   rS  rL   r   r   r^   r  r   rX  r  r$  r  r  )r   r  r  r>   idpythor0   r6   s           r   >test_name_error_bad_suggestions_do_not_trigger_for_small_nameszMNameErrorTests.test_name_error_bad_suggestions_do_not_trigger_for_small_names+  s@   %)))c)A)U\\s\## 	8 	88 8 8 8,.. 8#&778 8 8 8 8 8 8 8 8 8 8 8 8 8 88 Z888UCLLNN333UCLLNN333VS\\^^444UCLLNN333Y777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 \\s\## 	8 	88 8 8 8,.. 8#&778 8 8 8 8 8 8 8 8 8 8 8 8 8 88 Z888UCLLNN333UCLLNN333VS\\^^444UCLLNN333Y777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 \\s\## 	8 	88 8 8 8,.. 8#&778 8 8 8 8 8 8 8 8 8 8 8 8 8 88 Z888UCLLNN333UCLLNN333VS\\^^444UCLLNN333Y777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 \\t\$$ 	8 	88 8 8 8,.. 8#&778 8 8 8 8 8 8 8 8 8 8 8 8 8 88 Z888UCLLNN333UCLLNN333VS\\^^444UCLLNN333Y777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8s~  F+F
B	B A4(B4A88B;A8<B?FB		C3FFF)L+F32L3
H=H G<0H<H  HH HLHC3LLL1R3L;:R;
NN N8NNNNNRNC3RRR9X!;SX!
T!T  T TTTTTX!T!!C3X!!X%(X%c                 6   d }	  |             na# t           $ rT}t          j                    5 }t          j        t          j                      d d d            n# 1 swxY w Y   Y d }~nd }~ww xY w|                     |                                d           d S )Nc                     d x} x}x}x}x}x}x}x}x}x}	x}
x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x} x}!x}"x}#x}$x}%x}&x}'x}(x})x}*x}+x},x}-x}.x}/x}0x}1x}2x}3x}4x}5x}6x}7x}8x}9x}:x};x}<x}=x}>x}?x}@x}Ax}Bx}Cx}Dx}Ex}Fx}Gx}Hx}Ix}Jx}Kx}Lx}Mx}Nx}Ox}Px}Qx}Rx}Sx}Tx}Ux}Vx}Wx}Xx}Yx}Zx}[x}\x}]x}^x}_x}`x}ax}bx}cx}dx}ex}fx}gx}hx}ix}jx}kx}lx}mx}nx}ox}px}qx}rx}sx}tx}ux}vx}wx}xx}yx}zx}{x}|x}}x}~x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x} x}x}x}x}x}x}x}x}x}	x}
x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x} x}!x}"x}#x}$x}%x}&x}'x}(x})x}*x}+x},x}-x}.x}/x}0x}1x}2x}3x}4x}5x}6x}7x}8x}9x}:x};x}<x}=x}>x}?x}@x}Ax}Bx}Cx}Dx}Ex}Fx}Gx}Hx}Ix}Jx}Kx}Lx}Mx}Nx}Ox}Px}Qx}Rx}Sx}Tx}Ux}Vx}Wx}Xx}Yx}Zx}[x}\x}]x}^x}_x}`x}ax}bx}cx}dx}ex}fx}gx}hx}ix}jx}kx}lx}mx}nx}ox}px}qx}rx}sx}tx}ux}vx}wx}xx}yx}zx}{x}|x}}x}~x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x} x}x}x}x}x}x}x}x}x}	x}
x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x} x}!x}"x}#x}$x}%x}&x}'x}(x})x}*x}+x},x}-x}.x}/x}0x}1x}2x}3x}4x}5x}6x}7x}8x}9x}:x};x}<x}=x}>x}?x}@x}Ax}Bx}Cx}Dx}Ex}Fx}Gx}Hx}Ix}Jx}Kx}Lx}Mx}Nx}Ox}Px}Qx}Rx}Sx}Tx}Ux}Vx}Wx}Xx}Yx}Zx}[x}\x}]x}^x}_x}`x}ax}bx}cx}dx}ex}fx}gx}hx}ix}jx}kx}lx}mx}nx}ox}px}qx}rx}sx}tx}ux}vx}wx}xx}yx}zx}{x}|x}}x}~x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x} x}x}x}x}x}x}x}x}x}	x}
x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}x}}t          t                     d S r   )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a800s                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   r   rL  zXNameErrorTests.test_name_error_suggestions_do_not_trigger_for_too_many_locals.<locals>.fc  sW'   d aPB P Pb P2 P PR P" Pr PB P PPPP!P$'P*-P03P69P<?PBEPPPP!P$'P*-P03P69P<?PBEP P P P "P %(P +.P 14P 7:P =@P CFP 	P 	P 	P "	P %(	P +.	P 14	P 7:	P =@	P CF	P
 P
 P
 P
 "P
 %(P
 +.P
 14P
 7:P
 =@P
 CFP P P P "P %(P +.P 14P 7:P =@P CFP P P P "P %(P +.P 14P 7:P =@P CFP P P P "P %(P +.P 14P 7:P =@P CFP P P P "P %(P +.P 14P 7:P =@P CGP P P P "&P )-P 04P 7;P >BP EIP LPP P P P "&P )-P 04P 7;P >BP EIP LPP P P P "&P )-P 04P 7;P >BP EIP LPP P P P "&P )-P 04P 7;P >BP EIP LPP P P P "&P )-P 04P 7;P >BP EIP LPP P P P "&P )-P 04P 7;P >BP EIP LPP  !P  !P  !P  "&!P  )-!P  04!P  7;!P  >B!P  EI!P  LP!P" #P" #P" #P" "&#P" )-#P" 04#P" 7;#P" >B#P" EI#P" LP#P$ %P$ %P$ %P$ "&%P$ )-%P$ 04%P$ 7;%P$ >B%P$ EI%P$ LP%P& 'P& 'P& 'P& "&'P& )-'P& 04'P& 7;'P& >B'P& EI'P& LP'P( )P( )P( )P( "&)P( )-)P( 04)P( 7;)P( >B)P( EI)P( LP)P* +P* +P* +P* "&+P* )-+P* 04+P* 7;+P* >B+P* EI+P* LP+P, -P, -P, -P, "&-P, )--P, 04-P, 7;-P, >B-P, EI-P, LP-P. /P. /P. /P. "&/P. )-/P. 04/P. 7;/P. >B/P. EI/P. LP/P0 1P0 1P0 1P0 "&1P0 )-1P0 041P0 7;1P0 >B1P0 EI1P0 LP1P2 3P2 3P2 3P2 "&3P2 )-3P2 043P2 7;3P2 >B3P2 EI3P2 LP3P4 5P4 5P4 5P4 "&5P4 )-5P4 045P4 7;5P4 >B5P4 EI5P4 LP5P6 7P6 7P6 7P6 "&7P6 )-7P6 047P6 7;7P6 >B7P6 EI7P6 LP7P8 9P8 9P8 9P8 "&9P8 )-9P8 049P8 7;9P8 >B9P8 EI9P8 LP9P: ;P: ;P: ;P: "&;P: )-;P: 04;P: 7;;P: >B;P: EI;P: LP;P< =P< =P< =P< "&=P< )-=P< 04=P< 7;=P< >B=P< EI=P< LP=P> ?P> ?P> ?P> "&?P> )-?P> 04?P> 7;?P> >B?P> EI?P> LP?P@ AP@ AP@ AP@ "&AP@ )-AP@ 04AP@ 7;AP@ >BAP@ EIAP@ LPAPB CPB CPB CPB "&CPB )-CPB 04CPB 7;CPB >BCPB EICPB LPCPD EPD EPD EPD "&EPD )-EPD 04EPD 7;EPD >BEPD EIEPD LPEPF GPF GPF GPF "&GPF )-GPF 04GPF 7;GPF >BGPF EIGPF LPGPH IPH IPH IPH "&IPH )-IPH 04IPH 7;IPH >BIPH EIIPH LPIPJ KPJ KPJ KPJ "&KPJ )-KPJ 04KPJ 7;KPJ >BKPJ EIKPJ LPKPL MPL MPL MPL "&MPL )-MPL 04MPL 7;MPL >BMPL EIMPL LPMPN OPN OPN OPN "&OPN )-OPN 04OPN 7;OPN >BOPN EIOPN LPOPP QPP QPP QPP "&QPP )-QPP 04QPP 7;QPP >BQPP EIQPP LPQPR SPR SPR SPR "&SPR )-SPR 04SPR 7;SPR >BSPR EISPR LPSPT UPT UPT UPT "&UPT )-UPT 04UPT 7;UPT >BUPT EIUPT LPUPV WPV WPV WPV "&WPV )-WPV 04WPV 7;WPV >BWPV EIWPV LPWPX YPX YPX YPX "&YPX )-YPX 04YPX 7;YPX >BYPX EIYPX LPYPZ [PZ [PZ [PZ "&[PZ )-[PZ 04[PZ 7;[PZ >B[PZ EI[PZ LP[P\ ]P\ ]P\ ]P\ "&]P\ )-]P\ 04]P\ 7;]P\ >B]P\ EI]P\ LP]P^ _P^ _P^ _P^ "&_P^ )-_P^ 04_P^ 7;_P^ >B_P^ EI_P^ LP_P` aP` aP` aP` "&aP` )-aP` 04aP` 7;aP` >BaP` EIaP` LPaPb cPb cPb cPb "&cPb )-cPb 04cPb 7;cPb >BcPb EIcPb LPcPd ePd ePd ePd "&ePd )-ePd 04ePd 7;ePd >BePd EIePd LPePf gPf gPf gPf "&gPf )-gPf 04gPf 7;gPf >BgPf EIgPf LPgPh iPh iPh iPh "&iPh )-iPh 04iPh 7;iPh >BiPh EIiPh LPiPj kPj kPj kPj "&kPj )-kPj 04kPj 7;kPj >BkPj EIkPj LPkPl mPl mPl mPl "&mPl )-mPl 04mPl 7;mPl >BmPl EImPl LPmPn oPn oPn oPn "&oPn )-oPn 04oPn 7;oPn >BoPn EIoPn LPoPp qPp qPp qPp "&qPp )-qPp 04qPp 7;qPp >BqPp EIqPp LPqPr sPr sPr sPr "&sPr )-sPr 04sPr 7;sPr >BsPr EIsPr LPsPt uPt uPt uPt "&uPt )-uPt 04uPt 7;uPt >BuPt EIuPt LPuPv wPv wPv wPv "&wPv )-wPv 04wPv 7;wPv >BwPv EIwPv LPwPx yPx yPx yPx "&yPx )-yPx 04yPx 7;yPx >ByPx EIyPx LPyPz {Pz {Pz {Pz "&{Pz )-{Pz 04{Pz 7;{Pz >B{Pz EI{Pz LP{P| }P| }P| }P| "&}P| )-}P| 04}P| 7;}P| >B}P| EI}P| LP}P~ P~ P~ P~ "&P~ )-P~ 04P~ 7;P~ >BP~ EIP~ LPP@ AP@ AP@ AP@ "&AP@ )-AP@ 04AP@ 7;AP@ >BAP@ EIAP@ LPAPB CPB CPB CPB "&CPB )-CPB 04CPB 7;CPB >BCPB EICPB LPCPD EPD EPD EPD "&EPD )-EPD 04EPD 7;EPD >BEPD EIEPD LPEPF GPF GPF GPF "&GPF )-GPF 04GPF 7;GPF >BGPF EIGPF LPGPH IPH IPH IPH "&IPH )-IPH 04IPH 7;IPH >BIPH EIIPH LPIPJ KPJ KPJ KPJ "&KPJ )-KPJ 04KPJ 7;KPJ >BKPJ EIKPJ LPKPL MPL MPL MPL "&MPL )-MPL 04MPL 7;MPL >BMPL EIMPL LPMPN OPN OPN OPN "&OPN )-OPN 04OPN 7;OPN >BOPN EIOPN LPOPP QPP QPP QPP "&QPP )-QPP 04QPP 7;QPP >BQPP EIQPP LPQPR SPR SPR SPR "&SPR )-SPR 04SPR 7;SPR >BSPR EISPR LPSPT UPT UPT UPT "&UPT )-UPT 04UPT 7;UPT >BUPT EIUPT LPUPV WPV WPV WPV "&WPV )-WPV 04WPV 7;WPV >BWPV EIWPV LPWPX YPX YPX YPX "&YPX )-YPX 04YPX 7;YPX >BYPX EIYPX LPYPZ [PZ [PZ [PZ "&[PZ )-[PZ 04[PZ 7;[PZ >B[PZ EI[PZ LP[P\ ]P\ ]P\ ]P\ "&]P\ )-]P\ 04]P\ 7;]P\ >B]P\ EI]P\ LP]P^ _P^ _P^ _P^ "&_P^ )-_P^ 04_P^ 7;_P^ >B_P^ EI4"IIIIIr   zNameError.*a1)rL   r   r   r^   r  r   assertNotRegexr  r  s       r   >test_name_error_suggestions_do_not_trigger_for_too_many_localszMNameErrorTests.test_name_error_suggestions_do_not_trigger_for_too_many_localsb  s    S	 S	 S	j	4ACCCC 	4 	4 	4(** 4c"CLNN334 4 4 4 4 4 4 4 4 4 4 4 4 4 4	4 	CLLNN,<=====r  c                 f   d }	  |             na# t           $ rT}t          j                    5 }t          j        t          j                      d d d            n# 1 swxY w Y   Y d }~nd }~ww xY w|                     d|                                           d }	  |             na# t           $ rT}t          j                    5 }t          j        t          j                      d d d            n# 1 swxY w Y   Y d }~nd }~ww xY w|                     d|                                           d S )Nc                  "    d } t                      r   rL   r  s    r   rL  z@NameErrorTests.test_name_error_with_custom_exceptions.<locals>.f  s    E++r   r  c                      d } t           r   r  r  s    r   rL  z@NameErrorTests.test_name_error_with_custom_exceptions.<locals>.f  s    EOr   r  r  s       r   &test_name_error_with_custom_exceptionsz5NameErrorTests.test_name_error_with_custom_exceptions  s   	 	 		4ACCCC 	4 	4 	4(** 4c"CLNN334 4 4 4 4 4 4 4 4 4 4 4 4 4 4	4 	#,,..111	 	 		4ACCCC 	4 	4 	4(** 4c"CLNN334 4 4 4 4 4 4 4 4 4 4 4 4 4 4	4 	#,,..11111ss   
 
A.A) AA)A	A) A	!A))A.
B( (
D2D C1%D1C5	5D8C5	9DDc                 6   d }	  |             na# t           $ rT}t          j                    5 }t          j        t          j                      d d d            n# 1 swxY w Y   Y d }~nd }~ww xY w|                     d|                                           d S )Nc                  ,    d} t          |           d}d S )Nr   )r  )r  	somethongs     r   r   zDNameErrorTests.test_unbound_local_error_doesn_not_match.<locals>.foo  s    I)IIIr   r  )rZ  r   r   r^   r  r   rX  r  )r   r   r0   r6   s       r   (test_unbound_local_error_doesn_not_matchz7NameErrorTests.test_unbound_local_error_doesn_not_match  s    	 	 	
	4CEEEE  	4 	4 	4(** 4c"CLNN334 4 4 4 4 4 4 4 4 4 4 4 4 4 4	4 	cllnn55555r  c                 .     fd}	  |             nZ#  j         $ rM t          j                    5 }t          j        t          j                      d d d            n# 1 swxY w Y   Y nw xY w                     d|                                           d S )Nc                  ~                          t          d          5  t           d d d            d S # 1 swxY w Y   d S )Naaa)r   rL   aabr+   s   r   rL  z)NameErrorTests.test_issue45826.<locals>.f  s    ''	599                   s   266r!  )failureExceptionr   r   r^   r  r   r   r  r   rL  r6   s   `  r   test_issue45826zNameErrorTests.test_issue45826  s    	 	 	 	 		4ACCCC$ 	4 	4 	4(** 4c"CLNN334 4 4 4 4 4 4 4 4 4 4 4 4 4 4	4 	eS\\^^,,,,,s2   
 A* AA*A 	 A*#A 	$A*)A*c                 x   d }	  |             nZ# t           $ rM t          j                    5 }t          j        t          j                      d d d            n# 1 swxY w Y   Y nw xY w|                     d|                                           |                     d|                                           d S )Nc                      	 t            d S # t          $ r(} |                     d            t                      d } ~ ww xY wr   )nonsenser  r+  rZ   )r   s    r   rL  z1NameErrorTests.test_issue45826_focused.<locals>.f  sO    *  * * *  &&&')))*s    
=#8=r'  rZ   )rZ   r   r   r^   r  r   r   r  r#  s      r   test_issue45826_focusedz&NameErrorTests.test_issue45826_focused  s    	* 	* 	*	4ACCCC  	4 	4 	4(** 4c"CLNN334 4 4 4 4 4 4 4 4 4 4 4 4 4 4	4 	j#,,..111)3<<>>:::::s2   
 A' AA'A	A' A	!A'&A'N)r   r   r    r  r  r  r  r  r  r  r  r  r$  r(  r!   r   r   r  r    s        0 0 0+6 +6 +6ZC C C> > >C C C58 58 58n\> \> \>|2 2 226 6 6- - -; ; ; ; ;r   r  c                   \    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd ZdS )AttributeErrorTestsc                 8   t          d          }|                     |j                   |                     |j                   t	                      }t          dd|          }|                     |j        d           |                     |j        |           d S )NzOuch!Ouchcarryr  rc  )r;   r>  r  rc  r   r5   r   )r   r0   sentinels      r   test_attributesz#AttributeErrorTests.test_attributes  s    W%%#(####'"""88V'x@@@7+++cgx(((((r   c                     G d d          } |            }	 |j          nM# t          $ r@}|                     d|j                   |                     ||j                   Y d }~nd }~ww xY w	 t
                              |d           d S # t          $ rA}|                     d|j                   |                     ||j                   Y d }~d S d }~ww xY w)Nc                       e Zd ZdZdS )<AttributeErrorTests.test_getattr_has_name_and_obj.<locals>.ANr   r   r    r  r!   r   r   r  r3            EEEr   r  r  )r  r;   r5   r  rc  r   __getattribute__r   r  rc  r0   s       r   test_getattr_has_name_and_objz1AttributeErrorTests.test_getattr_has_name_and_obj  s%   	 	 	 	 	 	 	 	 acc	+III 	+ 	+ 	+Wch///S#'********	+	+##C11111 	+ 	+ 	+Wch///S#'*********	+s,   ! 
A+6A&&A+/B 
C6CCc                      G d d          } |            }	 |                                  d S # t          $ rA}|                     d|j                   |                     ||j                   Y d }~d S d }~ww xY w)Nc                       e Zd Zd ZdS )GAttributeErrorTests.test_getattr_has_name_and_obj_for_method.<locals>.Ac                     d S r   r!   r+   s    r   r  zMAttributeErrorTests.test_getattr_has_name_and_obj_for_method.<locals>.A.blech%  s    r   Nr4  r!   r   r   r  r;  $  s#            r   r  r  )r  r;   r5   r  rc  r7  s       r   (test_getattr_has_name_and_obj_for_methodz<AttributeErrorTests.test_getattr_has_name_and_obj_for_method#  s    	 	 	 	 	 	 	 	 acc	+IIKKKKK 	+ 	+ 	+Wch///S#'*********	+s   / 
A:6A55A:c                 
    G d d          } G d d          } G d d          } G d d          } G d	 d
          } G d d          }|df|df|df|df|df|dffD ]\  }}	  |            j          na# t          $ rT}	t          j                    5 }
t	          j        t	          j                      d d d            n# 1 swxY w Y   Y d }	~	nd }	~	ww xY w|                     ||
                                           d S )Nc                   "    e Zd ZdxZxZxZZdZdS )BAttributeErrorTests.test_getattr_suggestions.<locals>.SubstitutionN)r   r   r    r  r  r   r  r  r!   r   r   r  r@  0  s'        *..E.J.REEEr   r  c                   "    e Zd ZdxZxZxZZdZdS )AAttributeErrorTests.test_getattr_suggestions.<locals>.EliminationN)r   r   r    r  r  r   r  r  r!   r   r   r  rB  4  s'        *..E.J.RDDDr   r  c                   "    e Zd ZdxZxZxZZdZdS )>AttributeErrorTests.test_getattr_suggestions.<locals>.AdditionN)r   r   r    r  r  r   r  r  r!   r   r   r  rD  8  s'        *..E.J.RGGGr   r  c                       e Zd ZdZdZdS )QAttributeErrorTests.test_getattr_suggestions.<locals>.SubstitutionOverEliminationN)r   r   r    r  r  r!   r   r   r  rF  <  s        EDDDr   r  c                       e Zd ZdZdZdS )NAttributeErrorTests.test_getattr_suggestions.<locals>.SubstitutionOverAdditionN)r   r   r    r  r  r!   r   r   r  rH  @  s        EFFFr   r  c                       e Zd ZdZdZdS )MAttributeErrorTests.test_getattr_suggestions.<locals>.EliminationOverAdditionN)r   r   r    r  r  r!   r   r   r  rJ  D  s        FDDDr   r  r  r  r  z'bluc'?r  	r  r;   r   r   r^   r  r   r   r  )r   r  r  r  r  r  r  r  r  r0   r6   s              r   test_getattr_suggestionsz,AttributeErrorTests.test_getattr_suggestions/  s   	 	 	 	 	 	 	 		 	 	 	 	 	 	 		 	 	 	 	 	 	 		 	 	 	 	 	 	 		 	 	 	 	 	 	 		 	 	 	 	 	 	 	 ".z :!,i 8!)< 8!8) D!<j I!9: F H 	6 	6OC8! 8 8 8,.. 8#&778 8 8 8 8 8 8 8 8 8 8 8 8 8 88 MM*cllnn5555	6 	6s<   )A99
CC C6CCC	C
CCc                 T    G d d          }	  |            j          na# t          $ rT}t          j                    5 }t	          j        t	          j                      d d d            n# 1 swxY w Y   Y d }~nd }~ww xY w|                     d|                                           d S )Nc                       e Zd ZdZdS )ZAttributeErrorTests.test_getattr_suggestions_do_not_trigger_for_long_attributes.<locals>.ANr4  r!   r   r   r  rO  W  r5  r   r  r  )	somethingverywrongr;   r   r   r^   r  r   rX  r  r   r  r0   r6   s       r   ;test_getattr_suggestions_do_not_trigger_for_long_attributeszOAttributeErrorTests.test_getattr_suggestions_do_not_trigger_for_long_attributesV  s    	 	 	 	 	 	 	 		4ACC""" 	4 	4 	4(** 4c"CLNN334 4 4 4 4 4 4 4 4 4 4 4 4 4 4	4 	#,,..111117    
A=A8 A(A8(A,	,A8/A,	0A88A=c                 b    G d d          }|                      d          5  	 |j         na# t          $ rT}t          j                    5 }t          j        t          j                      d d d            n# 1 swxY w Y   Y d }~nd }~ww xY w|                     d|	                                           |                     d|	                                           |                     d|	                                           |                     d|	                                           |                     d	|	                                           |                     d
|	                                           d d d            n# 1 swxY w Y   |                      d          5  	 |j
         na# t          $ rT}t          j                    5 }t          j        t          j                      d d d            n# 1 swxY w Y   Y d }~nd }~ww xY w|                     d|	                                           |                     d|	                                           |                     d|	                                           |                     d|	                                           |                     d	|	                                           |                     d
|	                                           d d d            n# 1 swxY w Y   |                      d          5  	 |j         na# t          $ rT}t          j                    5 }t          j        t          j                      d d d            n# 1 swxY w Y   Y d }~nd }~ww xY w|                     d|	                                           |                     d|	                                           |                     d|	                                           |                     d|	                                           |                     d	|	                                           |                     d
|	                                           d d d            n# 1 swxY w Y   |                      d          5  	 |j         na# t          $ rT}t          j                    5 }t          j        t          j                      d d d            n# 1 swxY w Y   Y d }~nd }~ww xY w|                     d|	                                           |                     d|	                                           |                     d|	                                           |                     d|	                                           |                     d	|	                                           |                     d
|	                                           d d d            d S # 1 swxY w Y   d S )Nc                   "    e Zd ZdxZxZxZxZZdS )fAttributeErrorTests.test_getattr_error_bad_suggestions_do_not_trigger_for_small_names.<locals>.MyClassN)r   r   r    r  r  r>   r  r  r!   r   r   MyClassrV  c  s'        )--C-#--Br   rW  rS  r  r  r  r  r  r  r  r$  r  r  )r3   rS  r;   r   r   r^   r  r   rX  r  r$  r  r  )r   rW  r0   r6   s       r   Atest_getattr_error_bad_suggestions_do_not_trigger_for_small_nameszUAttributeErrorTests.test_getattr_error_bad_suggestions_do_not_trigger_for_small_namesb  sY   	. 	. 	. 	. 	. 	. 	. 	. \\s\## 	8 	88			! 8 8 8,.. 8#&778 8 8 8 8 8 8 8 8 8 8 8 8 8 88 Z888UCLLNN333UCLLNN333VS\\^^444UCLLNN333Y777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 \\s\## 	8 	88			! 8 8 8,.. 8#&778 8 8 8 8 8 8 8 8 8 8 8 8 8 88 Z888UCLLNN333UCLLNN333VS\\^^444UCLLNN333Y777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 \\s\## 	8 	88			! 8 8 8,.. 8#&778 8 8 8 8 8 8 8 8 8 8 8 8 8 88 Z888UCLLNN333UCLLNN333VS\\^^444UCLLNN333Y777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 \\t\$$ 	8 	88


! 8 8 8,.. 8#&778 8 8 8 8 8 8 8 8 8 8 8 8 8 88 Z888UCLLNN333UCLLNN333VS\\^^444UCLLNN333Y777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8s~  F.F
BB A7+B7A;;B>A;?BFBC3FFF,L.F65L6
H H G?3H?HHHH
LHC3LLL4R6L>=R>
NN N;NNNNNRNC3RR"R<X$>SX$
T$T# TTTTTTX$T$$C3X$$X(+X(c                     G d d          }t          d          D ]}t          |d| d            	  |            j         na# t          $ rT}t	          j                    5 }t          j        t          j                      d d d            n# 1 swxY w Y   Y d }~nd }~ww xY w| 	                    d|
                                           d S )Nc                       e Zd ZdZdS )TAttributeErrorTests.test_getattr_suggestions_do_not_trigger_for_big_dicts.<locals>.ANr4  r!   r   r   r  r[    r5  r   r  i  index_r  )rg   r6  r  r;   r   r   r^   r  r   rX  r  )r   r  indexr0   r6   s        r   5test_getattr_suggestions_do_not_trigger_for_big_dictszIAttributeErrorTests.test_getattr_suggestions_do_not_trigger_for_big_dicts  s2   	 	 	 	 	 	 	 	 4[[ 	/ 	/EA'''....	4ACCIII 	4 	4 	4(** 4c"CLNN334 4 4 4 4 4 4 4 4 4 4 4 4 4 4	4 	#,,..11111s;   A 
B#B" BBB	BB	BB#c                     G d d          }	  |            j          na# t          $ rT}t          j                    5 }t	          j        t	          j                      d d d            n# 1 swxY w Y   Y d }~nd }~ww xY w|                     d|                                            G d d          }	  |            j          na# t          $ rT}t          j                    5 }t	          j        t	          j                      d d d            n# 1 swxY w Y   Y d }~nd }~ww xY w|                     d|                                           d S )Nc                       e Zd ZdZd ZdS )?AttributeErrorTests.test_getattr_suggestions_no_args.<locals>.ANc                     t                      r   r;   r   attrs     r   __getattr__zKAttributeErrorTests.test_getattr_suggestions_no_args.<locals>.A.__getattr__  s    $&&&r   r   r   r    r  rf  r!   r   r   r  ra    s(        E' ' ' ' 'r   r  r  c                       e Zd ZdZd ZdS )ra  Nc                     t           r   rc  rd  s     r   rf  zKAttributeErrorTests.test_getattr_suggestions_no_args.<locals>.A.__getattr__  s    $$r   rg  r!   r   r   r  z?AttributeErrorTests.test_getattr_suggestions_no_args.<locals>.A  s(        E% % % % %r   rK  rQ  s       r    test_getattr_suggestions_no_argsz4AttributeErrorTests.test_getattr_suggestions_no_args  s   	' 	' 	' 	' 	' 	' 	' 	'
	4ACCIII 	4 	4 	4(** 4c"CLNN334 4 4 4 4 4 4 4 4 4 4 4 4 4 4	4 	gs||~~...	% 	% 	% 	% 	% 	% 	% 	%
	4ACCIII 	4 	4 	4(** 4c"CLNN334 4 4 4 4 4 4 4 4 4 4 4 4 4 4	4 	gs||~~.....ss    
A=A8 A(A8(A,	,A8/A,	0A88A=6C 
D$D# DDD	DD	DD$c                     G d d           G fdd          } G d d          } G d d          }|||fD ]}	  |            j          na# t          $ rT}t          j                    5 }t	          j        t	          j                      d d d            n# 1 swxY w Y   Y d }~nd }~ww xY w|                     d	|                                           d S )
Nc                       e Zd ZdZdZdS )TAttributeErrorTests.test_getattr_suggestions_invalid_args.<locals>.NonStringifyClassN)r   r   r    r,   __repr__r!   r   r   NonStringifyClassrm    s        GHHHr   ro  c                       e Zd ZdZ fdZdS )DAttributeErrorTests.test_getattr_suggestions_invalid_args.<locals>.ANc                 2    t                                 r   rc  )r   re  ro  s     r   rf  zPAttributeErrorTests.test_getattr_suggestions_invalid_args.<locals>.A.__getattr__  s    $%6%6%8%8999r   rg  )ro  s   r   r  rq    s3        E: : : : : : :r   r  c                       e Zd ZdZd ZdS )DAttributeErrorTests.test_getattr_suggestions_invalid_args.<locals>.BNc                 "    t          dd          )NError   rc  rd  s     r   rf  zPAttributeErrorTests.test_getattr_suggestions_invalid_args.<locals>.B.__getattr__  s    $Wb111r   rg  r!   r   r   r  rt    s(        E2 2 2 2 2r   r  c                       e Zd ZdZd ZdS )DAttributeErrorTests.test_getattr_suggestions_invalid_args.<locals>.CNc                      t          d          )Nrw  rc  rd  s     r   rf  zPAttributeErrorTests.test_getattr_suggestions_invalid_args.<locals>.C.__getattr__  s    $R(((r   rg  r!   r   r   r  ry    s(        E) ) ) ) )r   r  r  rK  )r   r  r  r  r  r0   r6   ro  s          @r   %test_getattr_suggestions_invalid_argsz9AttributeErrorTests.test_getattr_suggestions_invalid_args  s   	 	 	 	 	 	 	 		: 	: 	: 	: 	: 	: 	: 	: 	: 	:
	2 	2 	2 	2 	2 	2 	2 	2
	) 	) 	) 	) 	) 	) 	) 	)
 q!9 	3 	3C8! 8 8 8,.. 8#&778 8 8 8 8 8 8 8 8 8 8 8 8 8 88 MM'3<<>>2222	3 	3s<    A
B.B)- BB)BB) B!B))B.c                 T    G d d          }	  |            j          na# t          $ rT}t          j                    5 }t	          j        t	          j                      d d d            n# 1 swxY w Y   Y d }~nd }~ww xY w|                     d|                                           d S )Nc                       e Zd Zd ZdS )EAttributeErrorTests.test_getattr_suggestions_for_same_name.<locals>.Ac                     dgS )Nr  r!   r+   s    r   r(  zMAttributeErrorTests.test_getattr_suggestions_for_same_name.<locals>.A.__dir__  s
    y r   N)r   r   r    r(  r!   r   r   r  r~    s#        ! ! ! ! !r   r  Did you mean)	r  r;   r   r   r^   r  r   rX  r  rQ  s       r   &test_getattr_suggestions_for_same_namez:AttributeErrorTests.test_getattr_suggestions_for_same_name  s    	! 	! 	! 	! 	! 	! 	! 	!	4ACCIII 	4 	4 	4(** 4c"CLNN334 4 4 4 4 4 4 4 4 4 4 4 4 4 4	4 	88888rS  c                     G d d          }	  |            j          na# t          $ rT}t          j                    5 }t	          j        t	          j                      d d d            n# 1 swxY w Y   Y d }~nd }~ww xY w|                     d|                                           |                     d|                                           d S )Nc                       e Zd ZdZd ZdS )EAttributeErrorTests.test_attribute_error_with_failing_dict.<locals>.TrN   c                      t          d          )Noh no!rc  r+   s    r   r(  zMAttributeErrorTests.test_attribute_error_with_failing_dict.<locals>.T.__dir__  s    $X...r   N)r   r   r    r  r(  r!   r   r   Tr    s(        E/ / / / /r   r  r  r  )	blichr;   r   r   r^   r  r   rX  r  )r   r  r0   r6   s       r   &test_attribute_error_with_failing_dictz:AttributeErrorTests.test_attribute_error_with_failing_dict  s   	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/
	4ACCIII 	4 	4 	4(** 4c"CLNN334 4 4 4 4 4 4 4 4 4 4 4 4 4 4	4 	#,,..1113<<>>22222rS  c                 <   	 t          dd          # t           $ rT}t          j                    5 }t          j        t          j                      d d d            n# 1 swxY w Y   Y d }~nd }~ww xY w|                     d|                                           d S )N   rw  r.  ?)r;   r   r   r^   r  r   rX  r  )r   r0   r6   s      r   "test_attribute_error_with_bad_namez6AttributeErrorTests.test_attribute_error_with_bad_name  s    	4 bb1111 	4 	4 	4(** 4c"CLNN334 4 4 4 4 4 4 4 4 4 4 4 4 4 4	4 	cllnn-----s7    
A1A, AA,A 	 A,#A 	$A,,A1c                     G d d           G fdd          }	  |            j          na# t          $ rT}t          j                    5 }t	          j        t	          j                      d d d            n# 1 swxY w Y   Y d }~nd }~ww xY w|                     d|                                           |                     d|                                           d S )Nc                       e Zd ZdZdS )IAttributeErrorTests.test_attribute_error_inside_nested_getattr.<locals>.ArN   N)r   r   r    r  r!   r   r   r  r  	  s        EEEr   r  c                       e Zd Z fdZdS )IAttributeErrorTests.test_attribute_error_inside_nested_getattr.<locals>.Bc                 &                 }|j         S r   )r  )r   re  r   r  s      r   r6  zZAttributeErrorTests.test_attribute_error_inside_nested_getattr.<locals>.B.__getattribute__	  s    ACCwr   N)r   r   r    r6  )r  s   r   r  r  	  s.              r   r  r  r  )	r  r;   r   r   r^   r  r   r   r  )r   r  r0   r6   r  s       @r   *test_attribute_error_inside_nested_getattrz>AttributeErrorTests.test_attribute_error_inside_nested_getattr	  sJ   	 	 	 	 	 	 	 		 	 	 	 	 	 	 	 	 	
	4ACCMMM 	4 	4 	4(** 4c"CLNN334 4 4 4 4 4 4 4 4 4 4 4 4 4 4	4 	ncllnn555gs||~~.....s8   / 
BB A8,B8A<	<B?A<	 BBN)r   r   r    r0  r8  r=  rL  rR  rX  r^  rj  r{  r  r  r  r  r!   r   r   r*  r*    s        	) 	) 	)+ + + 
+ 
+ 
+%6 %6 %6N
2 
2 
268 68 68r2 2 2 / / /63 3 3:
9 
9 
93 3 3. . ./ / / / /r   r*  c                   &    e Zd Zd Zd Zd Zd ZdS )ImportErrorTestsc                    t          d          }|                     |j                   |                     |j                   t          dd          }|                     |j        d           |                     |j                   t          dd          }|                     |j        d           |                     |j                   t          ddd          }|                     |j        d           |                     |j        d           d}|                     t          |          5  t          dd	
           d d d            n# 1 swxY w Y   |                     t          |          5  t          ddd	           d d d            n# 1 swxY w Y   |                     t          |          5  t          ddd	           d d d            n# 1 swxY w Y   |                     t          |          5  t          d	
           d d d            n# 1 swxY w Y   |                     t          |          5  t          dd	d           d d d            d S # 1 swxY w Y   d S )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)rD   r>  r  r  r5   r   rX   )r   r0   rt   s      r   r0  z ImportErrorTests.test_attributes	  s   &!!#(####(###&|444<000#(###&z222:...#(###&z
CCC:...:...H##Is33 	3 	3	2222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 ##Is33 	@ 	@VY????	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ ##Is33 	@ 	@VY????	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ ##Is33 	+ 	+	****	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ ##Is33 	A 	A	4@@@@	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	AsZ   5EEE9FFF>GG!$G!H  H$'H$I&&I*-I*c                    t          ddd          }|                     |j        d           |                     |j        d           |                     |j        d           |                     |j        d           |                                 |                     |j        d           |                     |j        d            |                     |j        d            |                     |j        d            d S )Nr  r  r  r  r  r  r!   )rD   r5   r   rt   r  r  r   ry  s     r   test_reset_attributesz&ImportErrorTests.test_reset_attributes>	  s    &vF;;;9---&)))6***6*** 	2&&&$'''4(((4(((((r   c                     t          dt          fd          5  d}t          |          }|                     t	          |          t	          |                     d d d            d S # 1 swxY w Y   d S )Nr  T)quiets   abc)r   BytesWarningrD   r5   r4   )r   argr0   s      r   test_non_str_argumentz&ImportErrorTests.test_non_str_argumentL	  s    R.d;;; 	1 	1Cc""CSXXs3xx000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1s   AA((A,/A,c                 R   t                      t          d          t          d          t          dd          fD ]g}t          di |}t          t          j        dz             D ]}t          j        t          j        ||                    }|                     |j        d           |                     |j	        d           |                     |j
        |j
                   |                     |j        |j                   t          j        t          j        fD ]} ||          }|                     |j        d           |                     |j	        d           |                     |j
        |j
                   |                     |j        |j                   id S )	Nr  r  r  r  r  r  rN   r  )dictrD   rg   r  r  rc   r  r5   r   rt   r  r  copydeepcopy)r   kwargsorigprotor0   r  s         r   test_copy_picklez!ImportErrorTests.test_copy_pickleS	  s   vv,,,,,,*===? 	6 	6F 0000Dv6:;; 6 6l6<e#<#<==  9555  &111  49555  495555Y- 6 6agg  9555  &111  49555  4955556	6 	6r   N)r   r   r    r0  r  r  r  r!   r   r   r  r  	  sT         A  A  AD) ) )1 1 16 6 6 6 6r   r  c                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )SyntaxErrorTestsc                    dt          d          fdt          d          fdt          d          fdt          d          fdt          d	          fd
t          d	          fdt          d	          fdt          d	          fdt          d          fg	}|D ]\  }}|                     |          5  	 t          d|          # t          $ r~}t          j                    5 }t          j        t          j                      d d d            n# 1 swxY w Y   |                     ||	                                           |}Y d }~nd }~ww xY w	 d d d            n# 1 swxY w Y   d S )N)bad.pyrN   r   abcdefgrN   r   z
               File "bad.py", line 1
                 abcdefg
                  ^^^^^
             SyntaxError: bad bad
             )r  rN   r   r  rN   r   z
               File "bad.py", line 1
                 abcdefg
                  ^
             SyntaxError: bad bad
             )r  rN   r   r  rN   )r  rN   r   r  rN   r   z
               File "bad.py", line 1
                 abcdefg
                    ^
             SyntaxError: bad bad
             )r  rN   r  rN   r  zn
               File "bad.py", line 1
                 abcdefg
             SyntaxError: bad bad
             )r  rN   r  r  rN   )r  rN   r   r  rN   r   )r  rN   r   r  rN   r   r  rN   r   r  rN   d   z
               File "bad.py", line 1
                 abcdefg
                  ^^^^^^
             SyntaxError: bad bad
             )r   bad bad)
r   r3   rR   r   r   r^   r  r   r   r  )r   casesr   r  r0   r6   the_exceptions          r   test_range_of_offsetsz&SyntaxErrorTests.test_range_of_offsetsg	  sj    /  /  0  /  1  1  /  /  1 MN
^ $ 	( 	(ND(4(( ( ((%i666" ( ( ( 022 <c*CLNN;;< < < < < < < < < < < < < < <MM(CLLNN;;;$'MMMMMM	( "( ( ( ( ( ( ( ( ( ( ( ( ( ( (	( 	(sZ   0E2C
E
E D	?EDED-E EE

EE	!E	c                    d}	 t          t          dd          5 }|                    |           d d d            n# 1 swxY w Y   t          j        dddt                    \  }}}|                    d                                          }|                     |d	         d
           |                     |d         d           t          t                     n# t          t                     w xY wd}	 t          t          dd          5 }|                    |           d d d            n# 1 swxY w Y   t          j        dddt                    \  }}}|                    d                                          }|                     |d	         d           |                     |d         d           t          t                     d S # t          t                     w xY w)NuU   # -*- coding: cp437 -*-
"┬ó┬ó┬ó┬ó┬ó┬ó" + f(4, x for x in range(1))
r>   cp437r@   r,  -Xutf8r?   u@       "┬ó┬ó┬ó┬ó┬ó┬ó" + f(4, x for x in range(1))r  z-                          ^^^^^^^^^^^^^^^^^^^z# -*- coding: ascii -*-

(
r   z    (z    ^)	r_   r   writer	   r0  r   
splitlinesr5   r   )r   r   testfiler2  r3  r6   s         r   test_encodingszSyntaxErrorTests.test_encodings	  s*   M 			fcG444 'v&&&' ' ' ' ' ' ' ' ' ' ' ' ' ' '(>udFTZ[[LBS**W%%0022CSW&hiiiSW&UVVV6NNNNF6NNNN 2		fcG444 'v&&&' ' ' ' ' ' ' ' ' ' ' ' ' ' '(>udFTZ[[LBS**W%%0022CSWg...SWg...6NNNNNF6NNNNs]   C =C AC ABC C28G D1%G 1D55G 8D59BG G'c                    	 t          t          d          5 }|                    d           d d d            n# 1 swxY w Y   t          j        dddt                    \  }}}|                    d                                          }|                     d|d                    t          t                     d S # t          t                     w xY w)	Nbw   r,  r  r  r?   z8SyntaxError: Non-UTF-8 code starting with '\x89' in filer   )	r_   r   r  r	   r0  r   r  r   r   )r   r  r2  r3  r6   s        r   test_non_utf8zSyntaxErrorTests.test_non_utf8	  s    	fd## (xw'''( ( ( ( ( ( ( ( ( ( ( ( ( ( ((>udFTZ[[LBS**W%%0022CMMUWZ[]W^___6NNNNNF6NNNNs)   B= 9B= =B=  =A&B= =Cc                    d}t          d|          }|\  }}}}}}|                     ||j                   |                     ||j                   |                     ||j                   |                     ||j                   |                     ||j                   |                     ||j                   |                     d|j                   d S )Nr  r  	rR   r5   r   r   r   r   r   r   rt   )	r   r   r  r   r   r   errorr   r   s	            r   test_attributes_new_constructorz0SyntaxErrorTests.test_attributes_new_constructor	  s    2#It44BF?&&%Z=#9:::!5666]%=>>>!5666]%=>>> 2333M$566666r   c                    d}t          d|          }|\  }}}}|                     ||j                   |                     ||j                   |                     d |j                   |                     ||j                   |                     d |j                   |                     ||j                   |                     d|j                   d S )N)r  rN   r   r  r  r  )r   r   r  r   r   r   r  s          r   test_attributes_old_constructorz0SyntaxErrorTests.test_attributes_old_constructor	  s    *#It44*.'&&%=#9:::!5666}7888!5666}7888 2333M$566666r   c                     d}|                      t          t          d|           d}|                      t          t          d|           d}|                      t          t          d|           d S )N)r  rN   r   r  )r  rN   r   r   r   r   r   )r  rN   r   r  rN   )r\   rX   rR   r   r   s     r   test_incorrect_constructorz+SyntaxErrorTests.test_incorrect_constructor
  se    )[)TBBB+)[)TBBB-)[)TBBBBBr   N)	r   r   r    r  r  r  r  r  r  r!   r   r   r  r  f	  sw        X( X( X(t  :
 
 

7 
7 
7
7 
7 
7C C C C Cr   r  c                       e Zd Zd ZdS )TestInvalidExceptionMatcherc                 .   |                      t                    5  	 t          # d$ r Y nw xY w	 d d d            n# 1 swxY w Y   |                      t                    5  	 t          # t          df$ r Y nw xY w	 d d d            d S # 1 swxY w Y   d S )Nr!  )r\   rX   rY   r+   s    r   'test_except_star_invalid_exception_typezCTestInvalidExceptionMatcher.test_except_star_invalid_exception_type
  sF   y)) 	 	     		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 y)) 	 	  #   		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	sS   <$,<,<A A !B
#A**A96B
8A99B

BBN)r   r   r    r  r!   r   r   r  r  
  s#            r   r  c                   P    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd ZdS )PEP626Testsc                 `   	  |             |                      d           n# t          $ r}|j        }Y d }~nd }~ww xY wg }|j        }|r@|j        }|                    |j        d n|j        |j        j        z
             |j        }|@| 	                    t          |          |           d S )Nr1  )ri   r*   r-  tb_nextr   r  f_linenor   co_firstlinenor5   tuple)r   rL  r  r  tlinesframes          r   lineno_after_raisezPEP626Tests.lineno_after_raise
  s    	-ACCC II+,,,,  	! 	! 	! AAAAAA	! I 	JELL.u|::   	A  	 	ux00000s   
" 
=8=c                 8    d }|                      |d           d S )Nc                      ddz   d S r  r!   r!   r   r   simplez:PEP626Tests.test_lineno_after_raise_simple.<locals>.simple1
  s    aCCDr   rN   r  )r   r  s     r   test_lineno_after_raise_simplez*PEP626Tests.test_lineno_after_raise_simple0
  s/    	 	 	 	*****r   c                 8    d }|                      |d           d S )Nc                  ,    	 ddz   d S #  ddz   Y d S xY wr  r!   r!   r   r   	in_exceptz@PEP626Tests.test_lineno_after_raise_in_except.<locals>.in_except7
  s-    !!s   	 r   r  )r   r  s     r   !test_lineno_after_raise_in_exceptz-PEP626Tests.test_lineno_after_raise_in_except6
  s/    	 	 	 		1-----r   c                 8    d }|                      |d           d S )Nc                  B    	 ddz   d S # t           $ r} Y d } ~ d S d } ~ ww xY wr  )rX   r  s    r   other_exceptz@PEP626Tests.test_lineno_after_other_except.<locals>.other_except@
  s@    !   s   	 
r   r  )r   r  s     r   test_lineno_after_other_exceptz*PEP626Tests.test_lineno_after_other_except?
  s/    	 	 	
 	a00000r   c                 8    d }|                      |d           d S )Nc                  L    	 ddz   d S # t           $ r} ddz   Y d } ~ d S d } ~ ww xY wr  r)   r  s    r   in_named_exceptz@PEP626Tests.test_lineno_in_named_except.<locals>.in_named_exceptH
  sI    !   !s   	 
##r   r  )r   r  s     r   test_lineno_in_named_exceptz'PEP626Tests.test_lineno_in_named_exceptG
  s/    	 	 	 	33333r   c                 8    d }|                      |d           d S )Nc                      	 ddz   d S # w xY wr  r!   r!   r   r   in_tryz.PEP626Tests.test_lineno_in_try.<locals>.in_tryQ
  s    !s   	 r   r  )r   r  s     r   test_lineno_in_tryzPEP626Tests.test_lineno_in_tryP
  s/    	 	 	
 	*****r   c                 8    d }|                      |d           d S )Nc                  (    	 	 ddz   d S # ddz   w xY wr  r!   r!   r   r   in_finally_normalzDPEP626Tests.test_lineno_in_finally_normal.<locals>.in_finally_normalY
  s-    ! !s   r   r  )r   r  s     r   test_lineno_in_finally_normalz)PEP626Tests.test_lineno_in_finally_normalX
  0    	 	 	 	 1155555r   c                 8    d }|                      |d           d S )Nc                  0    	 ddz   ddz   d S # ddz   w xY wr  r!   r!   r   r   in_finally_exceptzDPEP626Tests.test_lineno_in_finally_except.<locals>.in_finally_exceptb
  s3    !! !s    r   r  )r   r  s     r   test_lineno_in_finally_exceptz)PEP626Tests.test_lineno_in_finally_excepta
  r  r   c                 X     G d d          fd}|                      |d           d S )Nc                       e Zd Zd Zd ZdS )0PEP626Tests.test_lineno_after_with.<locals>.Noopc                     | S r   r!   r+   s    r   rq  z:PEP626Tests.test_lineno_after_with.<locals>.Noop.__enter__l
  rr  r   c                     d S r   r!   r  s     r   rw  z9PEP626Tests.test_lineno_after_with.<locals>.Noop.__exit__n
  s    r   Nrx  r!   r   r   Noopr  k
  s2              r   r  c                  Z                  5  ddz   	 d d d            d S # 1 swxY w Y   d S r  r!   )r  s   r   
after_withz6PEP626Tests.test_lineno_after_with.<locals>.after_withp
  s      !                 s    $$r   r  )r   r
  r  s     @r   test_lineno_after_withz"PEP626Tests.test_lineno_after_withj
  sb    	 	 	 	 	 	 	 	
	 	 	 	 	 	
A.....r   c                     d }|                      |d           |j                            d          |_        |                      |d            d S )Nc                      ddz   d S r  r!   r!   r   r   rL  z8PEP626Tests.test_missing_lineno_shows_as_none.<locals>.fw
  s    aCCCCr   rN   s   )co_linetable)r  __code__r   )r   rL  s     r   !test_missing_lineno_shows_as_nonez-PEP626Tests.test_missing_lineno_shows_as_nonev
  s^    	 	 	1%%%Z''5T'UU
4(((((r   c                 Z     G d d          fd}|                      |dd           d S )Nc                       e Zd Zd Zd ZdS )CPEP626Tests.test_lineno_after_raise_in_with_exit.<locals>.ExitFailsc                     | S r   r!   r+   s    r   rq  zMPEP626Tests.test_lineno_after_raise_in_with_exit.<locals>.ExitFails.__enter__
  rr  r   c                     t           r   rN  r  s     r   rw  zLPEP626Tests.test_lineno_after_raise_in_with_exit.<locals>.ExitFails.__exit__
  s      r   Nrx  r!   r   r   	ExitFailsr  ~
  s2          ! ! ! ! !r   r  c                  X                  5  ddz   d d d            d S # 1 swxY w Y   d S r  r!   )r  s   r   r
  zDPEP626Tests.test_lineno_after_raise_in_with_exit.<locals>.after_with
  s|      !                 s   ##rN   r  )r   r
  r  s     @r   $test_lineno_after_raise_in_with_exitz0PEP626Tests.test_lineno_after_raise_in_with_exit}
  sd    	! 	! 	! 	! 	! 	! 	! 	!	 	 	 	 	 	
Aq11111r   N)r   r   r    r  r  r  r  r  r  r  r  r  r  r  r!   r   r   r  r  
  s        1 1 1$+ + +. . .1 1 14 4 4+ + +6 6 66 6 6
/ 
/ 
/) ) )
2 
2 
2 
2 
2r   r  __main__)-r  gcrq  r^   r  r  rz  r   textwrapr   test.supportr   r   r   r   r   r	   r
   test.support.import_helperr   test.support.os_helperr   r   test.support.warnings_helperr   r  r   r   r   rD   r*   r   r#   r'   TestCaser.   global_for_suggestionsr  r*  r  r  r  r  r   r  r!   r   r   <module>r"     sn    				 				 



          / / / / / / / / / / / / / / / / / / 5 4 4 4 4 4 1 1 1 1 1 1 1 1 7 7 7 7 7 7      !!!!!!!   GGG
    Y       I   
+ + + + + + + +f f f f fX& f f fP5  n; n; n; n; n;X& n; n; n;b	P/ P/ P/ P/ P/(+ P/ P/ P/fJ6 J6 J6 J6 J6x( J6 J6 J6XdC dC dC dC dCx( dC dC dCN    ("3   k2 k2 k2 k2 k2(# k2 k2 k2Z zHMOOOOO s   A A%$A%