
    daf92                    ^   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  G d
 de      Z G d de      Z G d de      Z  G d dejB                        Z" G d dejB                        Z# G d dejB                        Z$ G d dejB                        Z% G d dejB                        Z& G d dejB                        Z' G d dejB                        Z(e)dk(  r ejT                          yy# e$ r d	ZY w xY w)    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y)NaiveExceptionc                     || _         y Nxselfr   s     //root/Python-3.12.4/Lib/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y)SlottedNaiveExceptionr   c                     || _         y 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y)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                   l   e Zd Zd Zd Zd Zd ZdRd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!d Z"d Z#d Z$e%d         Z&d! Z'd" Z(d# Z)d$ Z*d% Z+d& Z,d' Z-d( Z.d) Z/d* Z0d+ Z1d, Z2d- Z3d. Z4d/ Z5d0 Z6d1 Z7d2 Z8d3 Z9d4 Z:d5 Z;d6 Z<d7 Z=d8 Z>d9 Z?d: Z@d; ZAe%d<        ZBe ej                   d
      d=               ZCed>        ZDed?        ZEd@ ZFedA        ZGedB        ZHedC        ZIedD        ZJe%dE        ZKdF ZLdG ZMdH ZNedI        ZOdJ ZPdK ZQdL ZR e
j,                  dMdN      dO        ZSdP ZTdQ ZUy)SExceptionTestsc                 H   | j                  ||      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                  ||       | j                  |j                  |       d d d        y # 1 sw Y   y xY w)N)excexcnamespam)subTeststrassertEqualr   )r   r0   r1   errbuf1buf2s         r   raise_catchzExceptionTests.raise_catch-   s    \\c7\3 
	4 &k!  3x  &k!  3x T4(S\\73
	4 
	4 
	4sH   B83B8BAA	ABA1BB!c                    | j                  t        d       | j                  t        t        t        d       | j                  t
        d       t        t        dd      }|j                          t        t        dd      }t        j                  }	 	 dd l
}|j                  d	       |t        _	        |j                          t        t               | j                  t        d
       | j                  t        t        dd       | j                  t        d       | j                  t        t        d       | j                  t         d       g }| j                  t         |j"                  d       | j                  t$        d       i }| j                  t$        |j"                  d       | j                  t&        d       | j                  t(        d       | j                  t*        d       t,        }| j                  t.        d       d}t1        d      D ]  }||z  }	 | j                  t2        d       | j                  t4        d       | j                  t6        d       t9        d       | j                  t:        d       | j                  t<        d       t?        ddd        | jA                  d!       | j                  tB        d"       | j                  tD        d#       | j                  tD        t        jF                  d       | j                  tH        d$       g d%z    | j                  tJ        d&       | j                  tJ        tL        d'       | j                  tN        d(       ddz  }| j                  tP        d)       ddz  }| j                  tR        d*       y # t
        $ r Y w xY w# |t        _	        |j                          t        t               w xY w# t*        $ r Y w xY w# t6        $ r Y w xY w# t<        $ r Y Uw xY w# tH        $ r Y w xY w# tN        $ r Y w xY w# tP        $ r
}Y d }~d }~ww xY w)+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:.&#0

&#0II			c" "CIHHJ6N),'4)CSIm4+z3EF\2*ammR8:.(AMM59*,?@m4K0#Q 	83Z 	EFA	 	~6)9:m4%[ 	)+=>:.@) ii-.m4\2*chh2K0"W 	\2*c62*,?@1Q 	K01Q 	+-ABK   "CIHHJ6N, $  D   $ !&$& #t#s   N )O O, O< P &P P* 	N*&N- )N**N- -,O	O)(O),	O98O9<	P	P		PP	P'&P'*	P=8P=c                 J      fd}d} ||d        |dd        |dd       y )Nc                     j                  | |      5  	 t        | dd       j                  d       d d d        y # t        $ r:}|j                  |k7  r!j                  d|d|j                         Y d }~Gd }~ww xY w# 1 sw Y   y xY w)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Cv6
 IIBCD D # Huu|		3"FGHD Ds1   B>B	B0A<7B<BBBzHif 1:
        try:
            continue
        except:
            passz'continue' not properly in loopz	continue
zf'{6 0}'z+invalid syntax. Perhaps you forgot a comma?r!   r   ry   ss   `  r   testSyntaxErrorMessagez%ExceptionTests.testSyntaxErrorMessage   s3    	D 	a23l=>jGHr   c                      t         f fd	}d} ||d       d} ||d       d} ||d       d} ||d       d} ||d       d	} ||d
       d} ||d
       d} ||dt               d} ||dt               y )Nc                     	 t        | dd       j                  d       y # |$ r?}|j                  |k7  r&j                  d|d|j                         Y d }~y Y d }~y 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
 		>?	  D55C<IIsAEEBCC  Ds   " A&0A!!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$aSTaST"aQRaQR
 !a!"a!" .aLN^_KaExPr   Nc                    | j                  |||      5  | j                  t              5 }t        |dd       d d d        | j	                  j
                  j                  |       | j	                  |j
                  j                  |       |&| j	                  |j
                  j                  |       |&| j	                  |j
                  j                  |       |j
                  j                  _t        |t              s|j                  |d      }|j                  d      |dz
     }| j                  ||j
                  j                         d d d        y # 1 sw Y   $xY w# 1 sw Y   y xY w)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 	7"";/ 32\623R\\00&9R\\00&9%  !8!8*E%  !8!8*E||  ,!#s+**Xy9Cyyvax0dBLL$5$56	7 	73 3	7 	7s"   E(EDE(E%	 E((E1c                 0    | j                   } |ddd       y )Nz"\
"(1 for c in I,\
\   )r   r   r   s     r   )test_error_offset_continuation_charactersz8ExceptionTests.test_error_offset_continuation_characters   s    

*Aq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        |d/dd$        |d0dd        |d1dd,        |d2dd        |d3dd$        |d4dd$        |d5dd$d6        |d7dd8        |d9dd        |d:dd        |d;dd        |d<d=d>        |d?dd@        |dAdd@        |dBddC        |dDj                         dddd        |dEdd        |dFdd@        |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       y )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gq!2Ar:#Q+;QCLh	(2Ar:h1A&na#,a4+Q211a8,a3-q!4I1bQoq!$mQ""Aq!R0'Aq"5"Aq!R0%q!Q3 	"Ar*$a+!1a(I1aP.15KQPQR 	h1iAj!QlAq!iAna#A&8!Q"	$ 	 B		 	8!Q?fa%q!,CQK  	 	  	 	 
 	 	n##%q!Q3 	11a8+Q3$a,CQK'A..15lAq!2Aq9 	3Q:-q!44a;j!Q%q!, !Q'.15!1a(oq!$!1a(r   z)Downcasting to int is safe for col_offsetcpur   F)memusedry_runc                     d|dfz  }| j                  t        d      5  t        |dd       d d d        y # 1 sw Y   y xY w)Ns   if True:
%*ss   passzParser column offset overflowru   rU   )assertRaisesRegexrM   rh   )r   sizers   s      r   testMemoryErrorBigSourcez'ExceptionTests.testMemoryErrorBigSourceH  sD     $0##M3RS 	/Cv.	/ 	/ 	/s   5>c                       G d dt                G d d       fd} fd} fd} |         |         |        y )Nc                       e Zd Zd Zy)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Dr   Nr   r!   r   r   BadExceptionr   U  s    Er   r   c                       e Zd Zy)=ExceptionTests.testSettingException.<locals>.InvalidExceptionNr   r   r    r!   r   r   InvalidExceptionr   Y      r   r   c                  N   dd l } 	 | j                  d       j                  d       y # t        $ rp}|j                  j
                  j                  }j                  |j                  d       j                  |j                  j                  d             Y d }~y d }~ww xY w)Nr   rN   Expected exception
test_capi1test_exceptions.py)	_testcapiraise_exceptionri   rX   __traceback__tb_framef_coder5   co_name
assertTrueco_filenameendswith)r   r6   cor   r   s      r   r   z7ExceptionTests.testSettingException.<locals>.test_capi1\  s    0)),: 		./  O&&//66  \: 7 78L MNNOs   + 	B$A&BB$c                     dd l } 	 | j                  d       j                  d       y # t        $ r}|j                  j
                  }|j                  j                  }j                  |j                  d       j                  |j                  j                  d             |j                  j                  j                  }j                  |j                  d       Y d }~y d }~ww xY w)Nr   r   r   r   
test_capi2)r   r   ri   rP   r   tb_nextr   r   r5   r   r   r   r   f_back)r   r6   tbr   co2r   r   s        r   r   z7ExceptionTests.testSettingException.<locals>.test_capi2g  s    
0)),: 		./   <&&..[[''  Z8 7 78L MNkk((//  l;;<s   + 	C,B.C''C,c                  R    dd l } j                  t        | j                  d       y )Nr   rN   )r   r\   rV   r   )r   r   r   s    r   
test_capi3z7ExceptionTests.testSettingException.<locals>.test_capi3u  s#    k9+D+D.3r   r)   )r   r   r   r   r   r   s   `   @@r   testSettingExceptionz#ExceptionTests.testSettingExceptionP  s;    
	E9 	E	 			0	0	3
 	r   c                    	 t          | j                  t         t               | j                  t	        t        d            d       | j                  t	        t        dd            d       t        ddd      }| j                  |j
                  d       | j                  |j                  d        | j                  t	        |      d       t        d	ddd
      }| j                  |j
                  d       | j                  |j                  d
       | j                  |j                  d       | j                  |j                  d       | j                  |j                  d        | j                  t	        |      d       t        d	dd d      }| j                  |j
                  d       | j                  |j                  d       | j                  |j                  d       | j                  |j                  d        | j                  |j                  d        | j                  t	        |      d       t        dd      }| j                  |j
                  d       | j                  |j                  d        | j                  |j                  d       | j                  |j                  d        | j                  |j                  d        y # t        $ r Y y 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~  s6   $	0 MM,0S/8Sy!9:35 5%(AQWWa(QZZ.SV%;<5%+AQWWa(QZZ+QZZ/QZZ/Q[[$/SV%>?5$-AQWWb)QZZ.QZZ/QZZ.Q[[$/SV%:;u%AQWWe,QZZ.QZZ/QZZ.Q[[$/E  		s   K 	KKwin32ztest specific to Windowsc                     t        d      }d}| j                  t        d|z        5  |j                  j	                  |       ddd       y# 1 sw Y   yxY w)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  sR     x(##G-AD-HI 	;44T:	; 	; 	;s   AAc                 \   t         di ddift         di ddift         di ddift         di ddift        di dddft        di dd d d d dft        d	i d	d d dd
dft        di d	dd dd
dft        di d	dddft        di dddddft        di ddddd dft        di d d d d d d d dft        di dd d dd d d d dft        di dd dd ddd!d"d#d$	ft        d%i d d%d dd d d d d d&	ft        di ddift
        d'i d'd(d)d*d+d,ft        d(t        d-      d*dd+fi d(t        d-      d*dd+fd(d-d*d+d,ft        d.i d.d(d-d*d+d,ft        d/i d/d0d1d*dd2ft        di ddd3ft        di ddd3ft        dt        d4d56      t        dd4d57      fg}	 |j                  t        di ddd ddd d8f       |D ]W  \  }}}}	  ||i |}t!        |      j"                  j%                  d9      s%| j'                  t!        |      j(                  d:       t+        |      }|D ]D  }t-        ||      }	| j'                  t/        |	      t/        ||         |d;|d<|	d=||          F t0        fD ]  }
t3        |
j4                  dz         D ]  }|
j7                  ||      }|
j9                  |      }|D ]X  }t/        t-        ||            }|t        k(  r|d5k(  rt/        d       }nt/        ||         }| j'                  ||d>|d?|       Z   Z y # t        $ r Y jw xY w#  t;        d@|dA|t<        j>                  B       Y xY w)CNr!   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   nameobjr  r  )r   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#   r;   dictappendr   rL   typer   r   r5   r   r4   r]   reprpicklerg   HIGHEST_PROTOCOLdumpsrc   printr^   stderr)r   exceptionListr0   r   kwargsexpectedro   r{   checkArgNamevaluepprotocolnewgotwants                  r   testAttributeszExceptionTests.testAttributes  s    BVbM2E27Hb(#%J*%'2"U35h"Td45 nb("$ u67 +R(#4 u67 92(u6RT@"5+z+-. 7,++4AB "b4$!dt"D#B C +r%)-x"t#%&
  GHJ')G *.x+-^MN  5685 *.x"t#49	: 2rFR>2 ":;=C%#)?AB  '9W+=q!"8":;="Ig$61+AC%')?AB   ":;=C%')?AB #$<b2$a)* Xr!.0"Hb!.0XtU'C(U;=iV
n
	  @"0"/d "/tEF ,9 #	@'Cvx"@(( Aw''001AB$$T!W%7%7DF$, EL#A|4E$$T%[%)(<*@%A%&%*H\,B&DEE ! @A$)!*<*<q*@$A @GGAx0ggaj,4 
@L"&wsL'A"BC"n49N (,Dz'+H\,B'C ,,S$./.?@
@@@+#	@  		HsgWTH5CJJGGs   7 K5 #L5	LL#L+c                    t        d      }d|_        | j                  |j                  d       | j                  |j                  d       | j	                  t
        t        |d       | j	                  t
        t        |d       |j                  ddd       | j                  |j                  d       | j                  |j                  d       | j                  |j                  d       | j                  |j                  d       |j                  d	d
dd       | j                  |j                  d
       | j                  |j                  d       | j                  |j                  d	       | j                  |j                  d       y )N*   5   )r"  r   brN   r   )r   r$  r   )rN   r   r   #   )r   r   blah)
r*   r&  r5   r   r\   r;   r]   __setstate__r   r$  r   ro   s     r   test_setstatezExceptionTests.test_setstate:  s&   bM'$.'1c:.'1c:	Qa()'$a a 	R"=>)$b!a r   c                     t        d      }| j                  t        d      5  |j                  d       d d d        y # 1 sw Y   y xY w)Nr"  zstate is not a dictionary)r*   r   rX   r'  r(  s     r   test_invalid_setstatez$ExceptionTests.test_invalid_setstateL  s=    bM##I/JK 	NN2	 	 	s	   =Ac                    t        d      t        d      t        d      fD ]  }| j                  |      5  | j	                  t        |d             |j                  d       | j                  |j                  dg       | j                  t              5  |j                  d       d d d        | j                  |j                  dg       |j                  d       | j                  |j                  ddg       |`| j	                  t        |d             |j                  d	       | j                  |j                  d	g       d|_        | j                  |j                  d       | j                  t              5  |j                  d
       d d d        | j                  |j                  d       d d d         y # 1 sw Y   xY w# 1 sw Y   >xY w# 1 sw Y   xY w)NrN   r   r   ro   	__notes__zMy Noter"  z	Your NotezOur Notezwill not work)r  r*   rY   r3   assertFalsehasattradd_noter5   r.  r\   rX   r(  s     r   
test_noteszExceptionTests.test_notesQ  s   "IaL*Q-@ 	2A" 2  K!89

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

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

:&  zl;   b1&&y1 0JJ/0  b1/2 2	2# # 0 0+2 2s=   AGG(CG?G$GGGGGG$	c                 4   	 t        d      # t        $ r}|j                  }Y d }~nd }~ww xY wt               j	                  |      }| j                  |t               | j                  |j                  |       t        d      j	                  |      }| j                  |t                | j                  |j                  |        G d dt              } |       j	                  |      }| j                  ||       | j                  |j                  |       y )Nr   r   c                       e Zd Zy)5ExceptionTests.testWithTraceback.<locals>.MyExceptionNr   r!   r   r   MyExceptionr5  z  r   r   r6  )rF   r*   r   r  with_tracebackassertIsInstancer5   )r   ro   r   r6  s       r   testWithTracebackz ExceptionTests.testWithTracebackl  s    	!Q- 	!B	! O**2.a/"-qM((,a,"-	) 	 M((,a-"-    	,',c                     	 dt               _        | j                  d       y # t        $ r%}| j	                  dt        |             Y d }~y 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.testInvalidTraceback  sJ    	-()IK% II+,  	GMM=s1vFF	Gs   # 	AAAc                    t         }t               }d}| j                  ||t        |dd       d}| j                  ||t        |dd       d}| j                  ||t        |dd       d}| j                  ||t        |d	d       y )
Nz'int' object is not iterabler   rN   z)__traceback__ must be a traceback or Noner   z9exception cause must be None or derive from BaseException	__cause__z;exception context must be None or derive from BaseException__context__)rX   r*   r   setattr)r   TEr0   rt   s       r   test_invalid_setattrz#ExceptionTests.test_invalid_setattr  s    k,r3fa@9r3oqIIr3k1EKr3mQGr   c                 $   t         }	 t        d      # t        $ r}|}Y d }~nd }~ww xY wd}| j                  ||t        |d       | j                  ||t        |d       | j                  ||t        |d       | j                  ||t        |d       y )Nr   zmay not be deletedr   r   r?  r@  )rX   rF   r*   r   delattr)r   rB  ro   r0   rt   s        r   test_invalid_delattrz#ExceptionTests.test_invalid_delattr  s    	Q- 	C	 #r3f=r3oFr3kBr3mDs    	(#(c                     	 t        d      # t        $ r}|j                  }Y d }~nd }~ww xY wt               }||_        d |_        | j                  |j                  d        y )Nr   )rF   r*   r   r5   )r   ro   r   s      r   testNoneClearsTracebackAttrz*ExceptionTests.testNoneClearsTracebackAttr  sU    	!Q- 	!B	! K$/r:  c                    t               }| j                  |j                         | j                  |j                         t	               }| j                  |j                         | j                  |j                          G d dt
              } |       }| j                  |j                         | j                  |j                         y )Nc                       e Zd Zy)5ExceptionTests.testChainingAttrs.<locals>.MyExceptionNr   r!   r   r   r6  rK    r   r   r6  )r*   assertIsNoner@  r?  rX   rC   )r   ro   r6  s      r   testChainingAttrsz ExceptionTests.testChainingAttrs  s    K!--(!++&K!--(!++&	' 	 M!--(!++&r   c                    	 t               # t         $ r}|}Y d }~nd }~ww xY w| j                  |j                         | j                  |j                         | j	                  |j
                         t               |_        d |_        | j                  |j                  t               | j                  |j                         | j                  |j
                         d|_        | j	                  |j
                         y )NF)	r*   rL  r@  r?  r/  __suppress_context__rL   r8  r   )r   r0   ro   s      r   testChainingDescriptorsz&ExceptionTests.testChainingDescriptors  s    	+ 	A	 	!--(!++&//0!ammY7!++&../!&//0s   
 	!!c                     | j                  t        t        d        G d dt              } |d      }| j                  |j                  d       y )NrN   )r   c                       e Zd Zd Zy)8ExceptionTests.testKeywordArgs.<locals>.DerivedExceptionc                 <    t         j                  |        || _        y r   )r  r   	fancy_arg)r   rU  s     r   r   zAExceptionTests.testKeywordArgs.<locals>.DerivedException.__init__  s    &&t,!*r   Nr   r!   r   r   DerivedExceptionrS    s    +r   rV  r"  )rU  )r\   rX   r  r5   rU  )r   rV  r   s      r   testKeywordArgszExceptionTests.testKeywordArgs  sE     	)]a8	+} 	+
 r*b)r   c                 t    fd| j                  t               fd| j                  t               y )Nc                               S r   r!   )fs   r   rZ  z/ExceptionTests.testInfiniteRecursion.<locals>.f  s
    3Jr   c                  2    	          S # t         $ r Y yw xY w)Nr   rY   gs   r   r^  z/ExceptionTests.testInfiniteRecursion.<locals>.g  s!    s
 s   
 	)r\   rQ   )r   rZ  r^  s    @@r   testInfiniteRecursionz$ExceptionTests.testInfiniteRecursion  s/    	.!,	
 	.!,r   c                     | j                  t        t                     | j                  t        t        d                   | j                  t        t        dd                   y )Nr   r$  )r   r4   r*   r+   s    r   test_strzExceptionTests.test_str  s?    I'IcN+,Ic3/01r   c                     	 t               # t         $ r }| j                  |t                Y d }~nd }~ww xY w| j                  dt                      | j	                  t
              5   d d d        y # 1 sw Y   y xY wNro   r*   r8  assertNotInlocalsr\   UnboundLocalErrorr(  s     r   test_exception_cleanup_namesz+ExceptionTests.test_exception_cleanup_names  sk    	0+ 	0!!!Y//	0fh'01 		 	 	s   
 	505'A33A<c                     	 t               # t         $ r!}| j                  |t                ~Y d }~nd }~ww xY w| j                  dt                      | j	                  t
              5   d d d        y # 1 sw Y   y xY wrc  rd  r(  s     r   test_exception_cleanup_names2z,ExceptionTests.test_exception_cleanup_names2  sm    	+ 	!!!Y/	 	fh'01 		 	 	s   
 	616(A44A=c                     G d dt                G d d      }fd} |       t        j                        }	  |        d t                 |       | j	                          |       t        j                        }	  |        d t                 |       | j	                          |       t        j                        }	  |        d t                 |       | j	                          |       t        j                        }dD ]
  }	  |         d t                 |       | j	                          |       t        j                        }	 	  |        	  |       t        j                        }	  |        d t        d      r
t                 |       | j	                          G d	 d
      } |       t        j                        } |       5   |        d d d        d t        d      r
t                 |       | j	                         y # $ r}Y d }~d }~ww xY w# $ r Y w xY w#  Y xY w#  Y  9xY w#  t
        xY w# t
        $ rL}d |_        d t                 |       t        d      r
t                | j	                         Y d }~Md }~ww xY w# $ r 	 	  #  xY w# $ r Y nw xY wY Lw xY w# 1 sw Y   xY w)Nc                       e Zd Zd Zy)=ExceptionTests.testExceptionCleanupState.<locals>.MyExceptionc                     || _         y r   r  r   r  s     r   r   zFExceptionTests.testExceptionCleanupState.<locals>.MyException.__init__
  	    r   Nr   r!   r   r   r6  rm  	      r   r6  c                       e Zd Zy)7ExceptionTests.testExceptionCleanupState.<locals>.MyObjNr   r!   r   r   MyObjrt    r   r   ru  c                      }        r   r!   )	local_refr6  r  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y)9ExceptionTests.testExceptionCleanupState.<locals>.Contextc                     | S r   r!   r+   s    r   	__enter__zCExceptionTests.testExceptionCleanupState.<locals>.Context.__enter__p      r   c                      y)NTr!   )r   exc_type	exc_valueexc_tbs       r   __exit__zBExceptionTests.testExceptionCleanupState.<locals>.Context.__exit__r  s    r   Nr   r   r    r}  r  r!   r   r   Contextr{  o  s    r   r  )r*   weakrefrefr   rL  rH   r@  r   )	r   ru  rx  wrro   ir  r6  r  s	          @@r   testExceptionCleanupStatez(ExceptionTests.testExceptionCleanupState  s   	) 		 		# g[[	  d# g[[	  d# g[[	  d# g[[ 	A"$	
 d# g[[	#"$$ g[[		  U+Ld#	 	
 g[[Y 	! 	!U+Ld#G  		  			 	#
 !AMCL$C /c""	#&  	 	,	! 	!s   H1 I I I'I! K 0K#1I<IIIII!I))I, ,	K5AJ<<KK KKKKK KK K #K,c                 X    fd}	 t          y # t        $ r |        Y d y d ww xY w)Nc                  
      y r   r!   r-  s   r   print_errorzIExceptionTests.test_exception_target_in_nested_scope.<locals>.print_error  s    r   )	somethingr*   )r   r  ro   s     @r   %test_exception_target_in_nested_scopez4ExceptionTests.test_exception_target_in_nested_scope~  s'    		 	MM	s    	)$)c                 B   d } |       }| j                  t        |      t               | j                  t	        j
                                | j                  t        |      t               | j                  t	        j
                                | j                  t        |             	 t        d      # t        $ r  |       }| j                  t        |      t               | j                  t	        j
                         t               | j                  t        |      t               | j                  t	        j
                         t               | j                  t        |      t               ~| j                  t	        j
                         t               Y y w xY w)Nc               3      K   	 t        d      # t         $ r/ t        j                          t        j                          Y nw xY wt        j                          y w)Ncaught)rH   r^   r   r!   r   r   yield_raisez:ExceptionTests.test_generator_leaking.<locals>.yield_raise  sK     &x(( &mmo%mmo%& --/!s    A! 5AA!AA!r   )r8  nextrH   rL  r^   r   rX   )r   r  r^  s      r   test_generator_leakingz%ExceptionTests.test_generator_leaking  s   	" Md1gx0#--/*d1gx0#--/*$q'"
	>E"" 	>A!!$q'84!!#--/9=!!$q'84!!#--/9=!!$q'95!!#--/9=	>s   *B5 5C&FFc                     d }	 t         # t         $ r  |       }t        |       Y nw xY w	 t        |       n# t        $ r Y nw xY w| j                  t	        j
                                y )Nc               3      K   d  y wr   r!   r!   r   r   r^  z1ExceptionTests.test_generator_leaking2.<locals>.g  s	        )rP   r  StopIterationrL  r^   r   r   r^  its      r   test_generator_leaking2z&ExceptionTests.test_generator_leaking2  sa    		 	BH		H 		#--/*s    ))9 	AAc                    d } |       }t        |       	 ddz   | j                  t        j                                y # t        $ ru}| j                  t        j                         |       |j                  |      }| j                  t        j                         |       | j                  ||       Y d }~d }~ww xY w)Nc               3   `   K   	 d  y # t         $ r t        j                          Y y w xY wwr   rZ   r^   r   r!   r   r   r^  z1ExceptionTests.test_generator_leaking3.<locals>.g  s(     &$ &mmo%&s   .	 .+.+.rN   r   )r  rZ   r   r^   r   throwrL  )r   r^  r  ro   gen_excs        r   test_generator_leaking3z&ExceptionTests.test_generator_leaking3  s    	&
 SR	&aC 	#--/* ! 	&MM#--/1-hhqkGMM#--/1-MM'1%%		&s   A   	B>	A+B99B>c                 l   d } |       }	 t         # t         $ r t        t        |            }Y nw xY w| j                  |t               	 t        |       n:# t        $ r.}| j                  t        j                         |       Y d }~nd }~ww xY w| j                  t        j                                y )Nc               3   `   K   	 ddz   y # t         $ r t        j                           w xY wwNrN   r   r  r!   r   r   r^  z1ExceptionTests.test_generator_leaking4.<locals>.g  s/     !$ mmo%s   .
 .!+.)rX   r  r  r   rZ   r^   r   rL  )r   r^  r  tpro   s        r   test_generator_leaking4z&ExceptionTests.test_generator_leaking4  s    	 S	 O 	  d2hB	  	b+,	.H ! 	.MM#--/1--	. 	#--/*s$    22A 	B!$B

Bc                       fd} |       }	 t         # t         $ r t        |       Y nw xY w j                  t        t        |       y )Nc               3      K    j                  t        j                         t               d   j	                  t        j                                y wr   )r8  r^   r   rP   rL  r+   s   r   r^  z>ExceptionTests.test_generator_doesnt_retain_old_exc.<locals>.g  s4     !!#--/<@cmmo.s   AA)rP   r  r\   r  r  s   `  r   $test_generator_doesnt_retain_old_excz3ExceptionTests.test_generator_doesnt_retain_old_exc  sD    	/ S	 	H	-r2s    ,,c                 ~    d fd} |        t                | j                  t        j                                y )Nc               3      K   d y wNrN   r!   r!   r   r   
simple_genzNExceptionTests.test_generator_finalizing_and_sys_exception.<locals>.simple_gen  s     Gr  c                  T            } 	 t         # t         $ r t        |       cY S w xY wr   )rP   r  )genr  s    r   run_genzKExceptionTests.test_generator_finalizing_and_sys_exception.<locals>.run_gen  s.    ,C!"" !Cy !s    '')r   rL  r^   r   )r   r  r  s     @r   +test_generator_finalizing_and_sys_exceptionz:ExceptionTests.test_generator_finalizing_and_sys_exception  s-    		! 		#--/*r   c                      G d dt                G d d      }fd} |       t        j                        } |       }t        |        ||       d x}t	                 |       | j                         y )Nc                       e Zd Zd Zy)FExceptionTests._check_generator_cleanup_exc_state.<locals>.MyExceptionc                     || _         y r   ro  rp  s     r   r   zOExceptionTests._check_generator_cleanup_exc_state.<locals>.MyException.__init__  rq  r   Nr   r!   r   r   r6  r    rr  r   r6  c                       e Zd Zy)@ExceptionTests._check_generator_cleanup_exc_state.<locals>.MyObjNr   r!   r   r   ru  r    r   r   ru  c               3   <   K   	         #  $ r d  Y y w xY wwr   r!   )r6  r  s   r   raising_genzFExceptionTests._check_generator_cleanup_exc_state.<locals>.raising_gen  s(     !#&& s    	)r*   r  r  r  r   rL  )r   testfuncru  r  r  r^  r6  r  s         @@r   "_check_generator_cleanup_exc_statez1ExceptionTests._check_generator_cleanup_exc_state  sm    	) 		 		 g[[MQCd#r   c                 ,    d }| j                  |       y )Nc                 V    	 | j                  t                      y # t        $ r Y y w xY wr   )r  rP   r]  s    r   do_throwzGExceptionTests.test_generator_throw_cleanup_exc_state.<locals>.do_throw  s'    ' s    	((r  )r   r  s     r   &test_generator_throw_cleanup_exc_statez5ExceptionTests.test_generator_throw_cleanup_exc_state  s    	
 	//9r   c                 ,    d }| j                  |       y )Nc                 $    | j                          y r   )r`   r]  s    r   do_closezGExceptionTests.test_generator_close_cleanup_exc_state.<locals>.do_close   s    GGIr   r  )r   r  s     r   &test_generator_close_cleanup_exc_statez5ExceptionTests.test_generator_close_cleanup_exc_state  s    	//9r   c                 ,    d }| j                  |       y )Nc                     d } y r   r!   r]  s    r   do_delzCExceptionTests.test_generator_del_cleanup_exc_state.<locals>.do_del%  s    Ar   r  )r   r  s     r   $test_generator_del_cleanup_exc_statez3ExceptionTests.test_generator_del_cleanup_exc_state$  s    	//7r   c                 2      fd} j                  |       y )Nc                 ^    	 t        |        j                  d       y # t        $ r Y y w xY wNz should have raised StopIteration)r  ri   r  r^  r   s    r   do_nextzEExceptionTests.test_generator_next_cleanup_exc_state.<locals>.do_next*  s2    >Q 		<= ! s     	,,r  )r   r  s   ` r   %test_generator_next_cleanup_exc_statez4ExceptionTests.test_generator_next_cleanup_exc_state)      	> 	//8r   c                 2      fd} j                  |       y )Nc                 j    	 | j                  d        j                  d       y # t        $ r Y y w xY wr  )sendri   r  r  s    r   do_sendzEExceptionTests.test_generator_send_cleanup_exc_state.<locals>.do_send4  s6    >t 		<= ! s   & 	22r  )r   r  s   ` r   %test_generator_send_cleanup_exc_statez4ExceptionTests.test_generator_send_cleanup_exc_state3  r  r   c                      G fdd      }d	 t         |             #  Y nxY wt                | j                         y )Nc                       e Zd Z fdZy)*ExceptionTests.test_3114.<locals>.MyObjectc                 .    t        j                         y r   )r^   r   r(  s    r   __del__z2ExceptionTests.test_3114.<locals>.MyObject.__del__A  s    MMOr   Nr   r   r    r  r-  s   r   MyObjectr  @  s    $r   r  r!   )r*   r   rL  )r   r  ro   s     @r   	test_3114zExceptionTests.test_3114=  sC    	$ 	$ 	HJ''	!s   ! %c                     G d dt               } G d dt               } G d dt               }	 	 |# |$ r}|}	 |# |$ r}|}	 |# |$ r}|}	| j                  ||       | j                  ||       | j                  |	|       | j                  |j                         | j	                  |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                  	       | j	                  |	j                         | j                  |j                         y )Nc                       e Zd Zy)HExceptionTests.test_raise_does_not_create_context_chain_cycle.<locals>.ANr   r!   r   r   Ar  M  r   r   r  c                       e Zd Zy)HExceptionTests.test_raise_does_not_create_context_chain_cycle.<locals>.BNr   r!   r   r   Br  O  r   r   r  c                       e Zd Zy)HExceptionTests.test_raise_does_not_create_context_chain_cycle.<locals>.CNr   r!   r   r   Cr  Q  r   r   r  )r*   r8  rL  r@  r   )r   r  r  r  a_r   b_r$  c_cro   r0   s               r   .test_raise_does_not_create_context_chain_cyclez=ExceptionTests.test_raise_does_not_create_context_chain_cycleL  sM   		 			 			 		    G  A
   --a3--a3--a3))!--8ammQ7ammQ7 	 	 "  	C	 	c1ammQ'ammQ'!--(sf   2 C-C(<C%C ACBCCC  C%%C((C--C0 0D5C<<Dc                    d }	  |        | j                  t               | j                  |j                  t               | j                  |j                  j                  |j                         y # t         $ r}|}Y d }~wd }~ww xY w)Nc                  `    	 t        d      # t         $ r} | | _        t        d      d } ~ ww xY wNrN   r   )rY   r@  rX   exs    r   cyclezBExceptionTests.test_no_hang_on_context_chain_cycle1.<locals>.cyclew  s2    # m# #!#l"#s    	-(-)r*   r8  rX   r@  rY   r   )r   r  ro   r0   s       r   $test_no_hang_on_context_chain_cycle1z3ExceptionTests.test_no_hang_on_context_chain_cycle1t  sj    	#	G 	c9-cooz:coo113??C  	C	s   A3 3	B<BBc                     G d dt               } G d dt               } G d dt               }| j                  |      5 }	  |       # |$ r>}|}	  |       # |$ r'}|}	  |       # |$ r}	|	}
|
|_        |
d }	~	ww xY wd }~ww xY wd }~ww xY w# 1 sw Y   nxY w| j                  j                  
       | j                  |
j                         | j                  |j                         | j                  |j                  |
       y )Nc                       e Zd Zy)>ExceptionTests.test_no_hang_on_context_chain_cycle2.<locals>.ANr   r!   r   r   r  r    r   r   r  c                       e Zd Zy)>ExceptionTests.test_no_hang_on_context_chain_cycle2.<locals>.BNr   r!   r   r   r  r    r   r   r  c                       e Zd Zy)>ExceptionTests.test_no_hang_on_context_chain_cycle2.<locals>.CNr   r!   r   r   r  r    r   r   r  r*   r\   r@  r   r   )r   r  r  r  r   _ar   _br$  _cr  s              r   $test_no_hang_on_context_chain_cycle2z3ExceptionTests.test_no_hang_on_context_chain_cycle2  s    		 			 			 	 q! 	 R c	  	 #I  A c	  () 	 	 	  	   	bllA&ammQ'ammQ'ammQ'se   BABBABA>A&&A;	+A6	6A;	;A>>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               }| j                  |      5 }	  |       # |$ r\}|}	  |       # |$ rE}	|	}
	  |       # |$ r.}|}||_        	  |       # |$ 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 Y   nxY w| j                  j                         | j                  |j                         | j                  |j                         | j                  |j                  
       | j                  |
j                         | j                  |j                  |       y )Nc                       e Zd Zy)>ExceptionTests.test_no_hang_on_context_chain_cycle3.<locals>.ANr   r!   r   r   r  r    r   r   r  c                       e Zd Zy)>ExceptionTests.test_no_hang_on_context_chain_cycle3.<locals>.BNr   r!   r   r   r  r    r   r   r  c                       e Zd Zy)>ExceptionTests.test_no_hang_on_context_chain_cycle3.<locals>.CNr   r!   r   r   r  r    r   r   r  c                       e Zd Zy)>ExceptionTests.test_no_hang_on_context_chain_cycle3.<locals>.DNr   r!   r   r   Dr    r   r   r	  c                       e Zd Zy)>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  r$  r  r  _ddro   s                   r   $test_no_hang_on_context_chain_cycle3z3ExceptionTests.test_no_hang_on_context_chain_cycle3  sb   		 			 			 			 			 	 q! 	$R$c	 $$#I $A
$c	 $()$"##I  $ "A !A"#G$$	$	$	$ 	$* 	bllA&ammQ'ammQ'ammQ'ammQ'ammQ's   C
A&&C+C.A55B?:B:=BB7			B2	BB/B**B//B2	2B7	7B::B??CCC

Cc                     	 	 t        d      }|# t        d      }|xY w# t        $ r}|}Y d }~nd }~ww xY w| j                  |       | j                  |j                         y r  )rX   rY   r*   r   r@  )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\] 	C	 	c2coor*s    ! 	616c                 @   	 	 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
                         | j	                  |j
                  j
                         y )NrN   r   r   )rX   rY   rC   r*   r   r@  )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\]QZ 	C	 	c2coor*coo1126s$    " 03 	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                  |       | j                  |j                         y r  )rY   rC   r*   r   r@  )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    		  ]	
 QZ QZ 	C	 	c2coor*s)   & & 7 47 	A AAc                    t        ddddd      }| j                  t        |      d       d|_        | j                  t        |      d       d|_        d	|_        | j                  t        |      d
       d|_        | j                  t        |      d       d|_        | j                  t        |      d       t        ddddd      }| j                  t        |      d       d|_        | j                  t        |      d       d|_        d	|_        | j                  t        |      d       d|_        | j                  t        |      d       d|_        | j                  t        |      d       t        dddd      }| j                  t        |      d       d|_        | j                  t        |      d       d|_        d	|_        | j                  t        |      d       d|_        | j                  t        |      d       y )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'Q!mn
Q!noQ!qruh1e<Q!VWQ!XY'Q!hi
Q!ijQ!lm!&!Q6Q!RSQ!WX'Q!deQ!ghr   c                     t         t        t        f}|D ],  }| j                  t	        |j                  |            d       . y )N )r	  r
  r  r5   r4   __new__)r   klassesklasss      r   test_unicode_errors_no_objectz,ExceptionTests.test_unicode_errors_no_object1  s=    $&8:OO 	<ESu!56;	<r   c                     G d dt               } G d dt        |      }t               5 }	 t               # |$ r}| j	                  d       Y d }~n%d }~wt        $ r Y n | j	                  d       Y nxY wd d d        n# 1 sw Y   nxY wfd        }| j                  |t        t        |             | j                  d	t        |             y )
Nc                       e Zd Zd Zy)/ExceptionTests.test_badisinstance.<locals>.Metac                     t               r   r\  )clssubclasss     r   __subclasscheck__zAExceptionTests.test_badisinstance.<locals>.Meta.__subclasscheck__<  s
     l"r   N)r   r   r    r*  r!   r   r   Metar&  ;  s    #r   r+  c                       e Zd Zy)6ExceptionTests.test_badisinstance.<locals>.MyExceptionNr   r!   r   r   r6  r-  >  r   r   r6  )	metaclasszShould have raised KeyErrorz%exception should not be a MyExceptionc                  D    	         S # t         $ r} | cY d } ~ S d } ~ ww xY wr   )rQ   )ro   r^  s    r   r^  z,ExceptionTests.test_badisinstance.<locals>.gM  s$    s
! s   
 	z maximum recursion depth exceeded)	r  r*   r   rH   ri   r8  rQ   r   r4   )r   r+  r6  r  ro   r0   r^  s         @r   test_badisinstancez!ExceptionTests.test_badisinstance7  s    	#4 	#	)t 	  
	9&	9j  C		ABB 9		78
	9 
	9 
	9	
 cc>49=8#c(Cs7   B
8A5ABA5B!A53BB
c                 @    d } |        t        j                          y )Nc                  P    t               } t        d      D ]  }| j                  }  y )Ni@B )r   rg   __dir__)or   s     r   r   z3ExceptionTests.test_trashcan_recursion.<locals>.foo\  s(    A9%  IIr   )r   r   )r   r   s     r   test_trashcan_recursionz&ExceptionTests.test_trashcan_recursionW  s    
	 	r   c                     dt         z  }t        j                  dd|      \  }}}| j                  |d       | j	                  d|       | j	                  d|       | j	                  d|       y )Na  if 1:
            import sys
            from _testinternalcapi import get_recursion_depth
            from test import support

            class MyException(Exception): pass

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

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

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

            generator = gen()
            next(generator)
            recursionlimit = sys.getrecursionlimit()
            try:
                recurse(support.EXCEEDS_RECURSION_LIMIT)
            finally:
                sys.setrecursionlimit(recursionlimit)
                print('Done.')
        -Wd-crN   s   RecursionErrors   ResourceWarning   Done.)__file__r	   assert_python_failurer5   r   r   r   rcoutr6   s        r   $test_recursion_normalizing_exceptionz3ExceptionTests.test_recursion_normalizing_exceptionf  sn    $H I$J %::5$MCQ'-(#.h$r   c                     d}t        j                  d|      \  }}}| j                  |d       d}| j                  ||v |d|d d d       | j	                  d	|       y )
Nzif 1:
            import _testcapi
            try:
                raise _testcapi.RecursingInfinitelyError
            finally:
                print('Done.')
        r8  rN   s0   RecursionError: maximum recursion depth exceededz not found in i  z... (truncated))rt   r9  )r	   r;  r5   r   r   )r   r   r=  r>  r6   r  s         r   -test_recursion_normalizing_infinite_exceptionz<ExceptionTests.test_recursion_normalizing_infinite_exception  sn    
 %::4FCQFC|>#fu+Xg-hih$r   c                 z   d }fdfdfdt        j                         }	  |d       fD ]6  }| j                  |      5  	  |        | j                  d       d d d        8 	 t        j
                  |       y # t        $ r Y ,w xY w# 1 sw Y   hxY w# t        j
                  |       w xY w)Nc                     d}	 	 t        j                  |       	 t        j                  || z          y # t        $ r |dz  }Y nw xY wEr  )r^   setrecursionlimitrQ   )ndepths     r   set_relative_recursion_limitzUExceptionTests.test_recursion_in_except_handler.<locals>.set_relative_recursion_limit  sS    E))%0 !!%'*	 & QJE s   4 AAc                  .    	 ddz   y #            Y y xY wr  r!   )recurse_in_excepts   r   rI  zJExceptionTests.test_recursion_in_except_handler.<locals>.recurse_in_except  s    $!$!#s   	 	c                  .    	 ddz             y #  Y xY wr  r!   )recurse_after_excepts   r   rK  zMExceptionTests.test_recursion_in_except_handler.<locals>.recurse_after_except  s!    ! !"s    c                  2    	           y #            Y y xY wr   r!   )recurse_in_body_and_excepts   r   rM  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   rD  )r   rG  recursionlimitrN  rK  rM  rI  s       @@@r    test_recursion_in_except_handlerz/ExceptionTests.test_recursion_in_except_handler  s    		+	$	#	- ..0	2(,*,@B\] I\\t\, II 		"GHI II !!.1 * I I !!.1sG   "B# BBB'
B# 	BBBBB 	B# #B:c                     d}t               5  t        j                  d|      \  }}}| j                  d|       d d d        y # 1 sw Y   y xY w)Na+  if 1:
            import _testcapi
            class C(): pass
            def recurse(cnt):
                cnt -= 1
                if cnt:
                    recurse(cnt)
                else:
                    _testcapi.set_nomemory(0)
                    C()
            recurse(16)
        r8     MemoryError)r
   r	   r;  r   r<  s        r   )test_recursion_normalizing_with_no_memoryz8ExceptionTests.test_recursion_normalizing_with_no_memory  sL     !" 	/(>>tTJLBSMM.#.	/ 	/ 	/s   -AAc                 l     dd l ddlm  fd} |       } |       } j                  ||       y )Nr   raise_memoryerrorc                      	          j                  d       j                        S # t        $ r} | j                  }Y d } ~ +d } ~ ww xY w)Nz Should have raised a MemoryError)ri   rK   r   	format_tb)ro   r   rW  r   	tracebacks     r   raiseMemErrorz6ExceptionTests.test_MemoryError.<locals>.raiseMemError  sI    >!# 		<=&&r**	  %__%s   , 	AAA)rZ  r   rW  r5   )r   r[  tb1tb2rW  rZ  s   `   @@r   test_MemoryErrorzExceptionTests.test_MemoryError  s0     	/	+ ooc"r   c                    dd l }d}d}| j                  t        |j                  d       |j                  d      }| j	                  t        |      t
               | j                  t        |t                     | j                  |j                         |j                  d|      }| j                  |j                  |       |j                  d|      }| j                  t        ||              G d	 d
t              }|j                  d|||f      }| j                  t        ||             | j                  t        ||             | j                  |j                  |       |j                  dd|ddi      }	| j                  t        |	|             | j                  |	j                  d       | j                  |	j                  d       y )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y)1ExceptionTests.test_exception_with_doc.<locals>.CNr   r!   r   r   r  rc  !  r   r   r  z_testcapi.error4z_testcapi.error5r  r   rN   )r   r\   rV   make_exception_with_docr   r  r   
issubclassr*   rL  __doc__r5   r   r   )
r   r   doc2doc4r`  error2error3r  error4error5s
             r   test_exception_with_docz&ExceptionTests.test_exception_with_doc  s   *0+y'H'H"	$ 223EFd6lD)
6956&..) 223EtL. 223E8> 3 @
6623	 	223Et4:A;@
6623
61-.. 223Er39C8E
66231%,r   c                 
   ddl m  G d d      d fd}	  |        | j                  d       t                | j                          d        y # t        $ r!}| j	                          d        Y d }~Gd }~ww xY w)Nr   rV  c                       e Zd Zy)3ExceptionTests.test_memory_error_cleanup.<locals>.CNr   r!   r   r   r  rp  5  r   r   r  c                  L            } t        j                  |                y r   r  r  )r  r  rW  r  s    r   innerz7ExceptionTests.test_memory_error_cleanup.<locals>.inner8  s    AQBr   zMemoryError not raised)r   rW  ri   rK   assertNotEqualr   r5   )r   rs  ro   r  rW  r  s      @@@r   test_memory_error_cleanupz(ExceptionTests.test_memory_error_cleanup0  ss     	0	 		 	0G II./t$  	,d++	,s   A 	B!A==Bc                      G d d      d fd	          | j                  d       t                | j	                          d        y # t        $ r!}| j                          d        Y d }~Gd }~ww xY w)Nc                       e Zd Zy)6ExceptionTests.test_recursion_error_cleanup.<locals>.CNr   r!   r   r   r  rx  J  r   r   r  c                  L            } t        j                  |                y r   rr  )r  r  rs  r  s    r   rs  z:ExceptionTests.test_recursion_error_cleanup.<locals>.innerM  s    AQBGr   zRecursionError not raised)ri   rQ   rt  r   r5   )r   ro   r  rs  r  s     @@@r   test_recursion_error_cleanupz+ExceptionTests.test_recursion_error_cleanupG  sn    	 			3G II12t$  	,d++	,s   A 	A<A77A<c                    | j                  t              5 }t        j                  t               d d d        | j                  j                  j                  t        j                  |j                         y # 1 sw Y   IxY wr   )	r\   rC   oslistdirr:  r5   r   r   ENOTDIR)r   r   s     r   test_errno_ENOTDIRz!ExceptionTests.test_errno_ENOTDIR\  sW    w' 	!2JJx 	!++U]]BLLI	! 	!s   A88Bc                 8    G d d      } |       }t        j                         5 }~t                | j                  |j                  j
                  |j                         | j                  |j                  j                         d d d        y # 1 sw Y   y xY w)Nc                       e Zd Zd Zy)1ExceptionTests.test_unraisable.<locals>.BrokenDelc                     t        d      }|)Nzdel is brokenr\  r   r0   s     r   r  z9ExceptionTests.test_unraisable.<locals>.BrokenDel.__del__e  s     1	r   Nr  r!   r   r   	BrokenDelr  d  s    r   r  )	r   catch_unraisable_exceptionr   r5   
unraisabler   r  assertIsNotNoneexc_traceback)r   r  r  r   s       r   test_unraisablezExceptionTests.test_unraisableb  sx    	 	 k//1 	>RLR]]1193D3DE  !<!<=	> 	> 	>s   A!BBc           	      d   t         t        fD ]  }| j                  |      5  	  |d      }| y # |$ rG t               5 }t	        j
                  t	        j                           d d d        n# 1 sw Y   nxY wY nw xY wj                         }| j                  d|       | j                  d|       | j                  |j                  |       |t        u r| j                  d|       n| j                  d|       | j                  |j                  d             d d d        # 1 sw Y   "xY w)Nztest messager   z	raise excz<exception str() failed>r   )rY   r'   r3   r   r^   __excepthook__exc_infogetvaluer   r   r   r   )r   r  r0   r  reports        r   test_unhandledzExceptionTests.test_unhandledr  s   #%78 	7Hh' 7<">2CI	7   <(* <f**CLLN;< < <<  *2F;k62h//811MM"<fEMM.&9 56!7 7 7s>   D%
/A;%A,	#	A;,A51A;8D%:A;;B D%%D/	c                     d}t        dd      D ]C  }t        j                  d||z        \  }}}| j                  |d       | j                  d|       E y )Nzif 1:
            import _testcapi
            class C(): pass
            _testcapi.set_nomemory(0, %d)
            C()
        rN   r   r8  )rN   x   rS  )rg   r	   r;  r   )r   r   r  r=  r>  r6   s         r   "test_memory_error_in_PyErr_PrintExz1ExceptionTests.test_memory_error_in_PyErr_PrintEx  sX     q" 	/A(>>tTAXNLBSMM"h'MM.#.	/r   c                      G d dt                G d dt               fd} |       }|j                  d        | j                        5  |j                                 d d d        y # 1 sw Y   y xY w)Nc                       e Zd Zy)BExceptionTests.test_yield_in_nested_try_excepts.<locals>.MainErrorNr   r!   r   r   	MainErrorr    r   r   r  c                       e Zd Zy)AExceptionTests.test_yield_in_nested_try_excepts.<locals>.SubErrorNr   r!   r   r   SubErrorr    r   r   r  c               3   P   K   	          #  $ r 	 d   # $ r Y  w xY ww xY wwr   r!   )r  r  s   r   mainz=ExceptionTests.test_yield_in_nested_try_excepts.<locals>.main  sF     k!     s(   & ####&)r*   r  r\   r  )r   r  coror  r  s      @@r    test_yield_in_nested_try_exceptsz/ExceptionTests.test_yield_in_nested_try_excepts  se    		 		y 		 v		$y) 	#JJxz"	# 	# 	#s   A00A9c                       fd} |       }	 t         # t         $ r  j                  t        |      d       Y nw xY w j                  t        |      d       y )Nc               3      K   	 t         # t         $ r d Y nw xY w j                  t        j                                d y wr  )rY   rL  r^   r   r+   s   r   r^  z?ExceptionTests.test_generator_doesnt_retain_old_exc2.<locals>.g  s?        cmmo.Gs   A A+ArN   r   )rF   r5   r  )r   r^  r  s   `  r   %test_generator_doesnt_retain_old_exc2z4ExceptionTests.test_generator_doesnt_retain_old_exc2  sS    	 c	+ 	+T#Y*	+cA&s    $<<c                     d }| j                  t              5   |       }	 ddz   d d d        y #  t        |       t        |       Y #xY w# 1 sw Y   y xY w)Nc               3      K   d  wr  r!   r!   r   r   r^  z1ExceptionTests.test_raise_in_generator.<locals>.g  s     Gr  rN   r   )r\   rZ   r  )r   r^  r  s      r   test_raise_in_generatorz&ExceptionTests.test_raise_in_generator  sZ    	
 01 	A!	 	QQ	 	s   A0A
AATz Won't work if __debug__ is Falsec                     t         a	 J d       # t        $ r<}b| j	                  |t               | j                  t        |      d       Y d }~y d }~ww xY w)Nhello)rX   AssertionErrorri   r  r8  r5   r4   r(  s     r   test_assert_shadowingz$ExceptionTests.test_assert_shadowing  sR    
 #	,!'!5 	.!!!^4SVW--	.s    	A2AA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                + y )Nc                       e Zd Zy)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 		 	D		 		 r 	A!!  L	s.    	,',2 	>>A	A)$A)c                     dt         j                   d}t        j                  d|      \  }}}| j	                  d|       y )NzOif 1:
            import _testcapi
            _testcapi.run_in_subinterp("[0]*z")
            exit(0)
        r8  rS  )r^   maxsizer	   assert_python_okr   )r   r   r=  r  r6   s        r   test_memory_error_in_subinterpz-ExceptionTests.test_memory_error_in_subinterp  sD    ..1kk] ;	
 #33D$?
Asnc*r   )NNr?   )Vr   r   r    r9   rp   r|   r   r   r   r   unittestskipIfr   r^   r  r   requires_resource
bigmemtestr   r   r   r   
skipUnlessplatformr   r   r)  r+  r2  r9  r=  rC  rF  rH  rM  rP  rW  r   r_  ra  rh  rj  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r#  r0  r5  r?  rA  rQ  rT  r^  rm  ru  rz  r  r  r  r  r  r  r  r  r  r  r!   r   r   r.   r.   +   s   4RChI0'QR7"2b)H X__W+-XYWu%W59/ : & Z/
 + +Z%0N X035;5;I@V!$
26.*-
HE	0' 1$* 
- 
-2		wr><++&+6
3+2::
8
99&)PD&"(H-(^+7$+$#iJ< D D> Wu% &  4% 4%l % %$,2^ / /* # #$ %- %-N % %, % %(J> 7* / / #.'$ X$FG, H,<+r   r.   c                   $    e Zd Zd Zd Zd Zd Zy)NameErrorTestsc                 v    	 t          y # t        $ r&}| j                  d|j                         Y d }~y d }~ww xY w)Nbluch)r  rL   r5   r  r  s     r   test_name_error_has_namez'NameErrorTests.test_name_error_has_name  s1    	0 	0Wchh//	0s   	 	838c                 &     fd}	  |         j                  dj                                y #  j                   $ rQ t        j                         5 }t        j                  t        j
                           d d d        n# 1 sw Y   nxY wY w xY w)Nc                  h     j                  t        d      5  t         d d d        y # 1 sw Y   y xY w)Naaa)r   rL   aabr+   s   r   rZ  z)NameErrorTests.test_issue45826.<locals>.f  s+    ''	59   s   (1r  )failureExceptionr   r   r^   r  r  r   r  r   rZ  r6   s   `  r   test_issue45826zNameErrorTests.test_issue45826  sv    		4C
 	eS\\^,	 $$ 	4((* 4c""CLLN34 4 4	4s'   0 #B%B8	BB
	BBc                 T   d }	  |        | j                  dj                                | j                  d|j                                y # t         $ rQ t        j                         5 }t        j                  t        j
                           d d d        n# 1 sw Y   nxY wY w xY w)Nc                  j    	 t          y # t        $ r } | j                  d        t               d } ~ ww xY wr   )nonsenser  r7  rZ   )r  s    r   rZ  z1NameErrorTests.test_issue45826_focused.<locals>.f#  s1    *  *  &'))*s   	 	2-2r  rZ   )rZ   r   r   r^   r  r  r   r  r  s      r   test_issue45826_focusedz&NameErrorTests.test_issue45826_focused"  s    	*	4C
 	j#,,.1)3<<>: ! 	4((* 4c""CLLN34 4 4	4s)   A B'*%B	B'B!	B'&B'c                 6    d }| j                  t        |       y )Nc                        G  fdd       y )Nc                       e Zd ZW   y);NameErrorTests.test_gh_111654.<locals>.f.<locals>.TestClassNr   	TestClasss   r   r  r  5  s    r   r  r!   r  s   @r   rZ  z(NameErrorTests.test_gh_111654.<locals>.f4  s     r   )r\   rL   r   rZ  s     r   test_gh_111654zNameErrorTests.test_gh_1116543  s    	 	)Q'r   N)r   r   r    r  r  r  r  r!   r   r   r  r    s    0-;"(r   r  c                       e Zd Zd Zd Zd Zy)AttributeErrorTestsc                 &   t        d      }| j                  |j                         | j                  |j                         t	               }t        dd|      }| j                  |j                  d       | j                  |j                  |       y )NzOuch!Ouchcarryr  )r;   rL  r  r  r   r5   r   )r   r0   sentinels      r   test_attributesz#AttributeErrorTests.test_attributes>  sk    W%#((##''"8V'x@7+cggx(r   c                     G d d      } |       }	 |j                    	 t
        j                  |d       y # t        $ rB}| j                  d|j                         | j                  ||j                         Y d }~^d }~ww xY w# t        $ rB}| j                  d|j                         | j                  ||j                         Y d }~y d }~ww xY w)Nc                       e Zd ZdZy)<AttributeErrorTests.test_getattr_has_name_and_obj.<locals>.ANr   r   r    blechr!   r   r   r  r  J  s    Er   r  r  )r  r;   r5   r  r  r   __getattribute__r   r  r  r0   s       r   test_getattr_has_name_and_objz1AttributeErrorTests.test_getattr_has_name_and_objI  s    	 	 c	+II	+##C1	  	+Wchh/S#''**	+
  	+Wchh/S#''**	+s,   7 B 	B 8A==B	C8CCc                      G d d      } |       }	 |j                          y # t        $ rB}| j                  d|j                         | j                  ||j                         Y d }~y d }~ww xY w)Nc                       e Zd Zd Zy)GAttributeErrorTests.test_getattr_has_name_and_obj_for_method.<locals>.Ac                      y r   r!   r+   s    r   r  zMAttributeErrorTests.test_getattr_has_name_and_obj_for_method.<locals>.A.blech[  s    r   Nr  r!   r   r   r  r  Z  s    r   r  r  )r  r;   r5   r  r  r  s       r   (test_getattr_has_name_and_obj_for_methodz<AttributeErrorTests.test_getattr_has_name_and_obj_for_methodY  s^    	 	 c	+IIK 	+Wchh/S#''**	+s   $ 	A/8A**A/N)r   r   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y)ImportErrorTestsc                 Z   t        d      }| j                  |j                         | j                  |j                         t        dd      }| j	                  |j                  d       | j                  |j                         t        dd      }| j	                  |j                  d       | j                  |j                         t        ddd      }| j	                  |j                  d       | j	                  |j                  d       d}| j                  t        |      5  t        dd	
       d d d        | j                  t        |      5  t        ddd	       d d d        | j                  t        |      5  t        ddd	       d d d        | j                  t        |      5  t        d	
       d d d        | j                  t        |      5  t        dd	d       d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   zxY w# 1 sw Y   [xY w# 1 sw Y   y xY w)Ntest
somemoduler  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   rL  r  r  r5   r   rX   )r   r0   rt   s      r   r  z ImportErrorTests.test_attributesj  s   &!#((##((#&|4<0#((#&z2:.#((#&z
C:.:.H##Is3 	3	2	3 ##Is3 	@VY?	@ ##Is3 	@VY?	@ ##Is3 	+	*	+ ##Is3 	A	4@	A 	A	3 	3	@ 	@	@ 	@	+ 	+	A 	As<   (G1G=H	.HH!1G:=H	HH!H*c                     t        ddd      }| j                  |j                  d       | j                  |j                  d       | j                  |j                  d       | j                  |j
                  d       |j                          | j                  |j                  d       | j                  |j                  d        | j                  |j                  d        | j                  |j
                  d        y )Nr  r  r  r  r  r  r!   )rD   r5   r   rt   r  r  r   r  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        |      }| j                  t	        |      t	        |             d d d        y # 1 sw Y   y xY w)Nr  T)quiets   abc)r   BytesWarningrD   r5   r4   )r   argr0   s      r   test_non_str_argumentz&ImportErrorTests.test_non_str_argument  sM    R.d; 	1Cc"CSXs3x0	1 	1 	1s   2AAc                    t               t        d      t        d      t        dd      fD ]  }t        di |}t        t        j                  dz         D ]  }t        j
                  t        j                  ||            }| j                  |j                  d       | j                  |j                  d       | j                  |j                  |j                         | j                  |j                  |j                          t        j                  t        j                  fD ]  } ||      }| j                  |j                  d       | j                  |j                  d       | j                  |j                  |j                         | j                  |j                  |j                           y )	Nr  r  r  r  r  r  rN   r  )r  rD   rg   r  r  rc   r  r5   r   rt   r  r  copydeepcopy)r   r  origprotor0   r  s         r   test_copy_picklez!ImportErrorTests.test_copy_pickle  sP   v,,*=? 	6F 00Dv66:; 6ll6<<e#<=  95  &1  4995  49956 YY- 6g  95  &1  4995  49956	6r   N)r   r   r    r  r  r  r  r!   r   r   r  r  h  s     AD)16r   r  c                   0    e Zd Zd Zd Zd Zd Zd Zd Zy)SyntaxErrorTestsc                 j   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 ]$  \  }}| j                  |      5  	 t        d|       y # t        $ rz}t        j                         5 }t        j                  t        j                           d d d        n# 1 sw Y   nxY w| j                  |j                                |}Y d }~nd }~ww xY w	 d d d        # 1 sw Y   xY w)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_offsets  s    / / 0 / 1 1 / / 1MN
^ $ 	(ND(4( ((%i66	( # ( 002 <c**CLLN;< < <MM(CLLN;$'M	( "( ( (sH   	D)B	D"D6%C$		D$C-))DD)DD))D2	c                 "   d}	 t        t        dd      5 }|j                  |       d d d        t        j                  dddt              \  }}}|j                  d      j                         }| j                  |d	   d
       | j                  |d   d       t        t               d}	 t        t        dd      5 }|j                  |       d d d        t        j                  dddt              \  }}}|j                  d      j                         }| j                  |d	   d       | j                  |d   d       t        t               y # 1 sw Y   *xY w# t        t               w xY w# 1 sw Y   xY w# t        t               w xY w)NuU   # -*- coding: cp437 -*-
"┬ó┬ó┬ó┬ó┬ó┬ó" + f(4, x for x in range(1))
r>   cp437r@   r7  -Xutf8r?   u@       "┬ó┬ó┬ó┬ó┬ó┬ó" + f(4, x for x in range(1))r  z-                          ^^^^^^^^^^^^^^^^^^^z# -*- coding: ascii -*-

(
r   z    (z    ^)	r_   r   writer	   r;  r   
splitlinesr5   r   )r   r   testfiler=  r>  r6   s         r   test_encodingszSyntaxErrorTests.test_encodings  sX   M 			fcG4 'v&'(>>udFTZ[LBS**W%002CSW&hiSW&UV6N 2		fcG4 'v&'(>>udFTZ[LBS**W%002CSWg.SWg.6N+' ' 6N
' ' 6NsG   E EA1E +E= =E1A1E= EE E.1E:6E= =Fc                 `   	 t        t        d      5 }|j                  d       d d d        t        j                  dddt              \  }}}|j                  d      j                         }| j                  d|d          t        t               y # 1 sw Y   mxY w# t        t               w xY w)	Nbw   r7  r  r  r?   z8SyntaxError: Non-UTF-8 code starting with '\x89' in filer   )	r_   r   r  r	   r;  r   r  r   r   )r   r  r=  r>  r6   s        r   test_non_utf8zSyntaxErrorTests.test_non_utf8,  s    	fd# (xw'((>>udFTZ[LBS**W%002CMMUWZ[]W^_6N( ( 6Ns"   B BAB BB B-c                    d}t        d|      }|\  }}}}}}| j                  ||j                         | j                  ||j                         | j                  ||j                         | j                  ||j
                         | j                  ||j                         | j                  ||j                         | j                  d|j                         y )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_constructor8  s    2#It4BF?&&%Z=#9#9:!5!56]%=%=>!5!56]%=%=> 2 23M$5$56r   c                    d}t        d|      }|\  }}}}| j                  ||j                         | j                  ||j                         | j                  d |j                         | j                  ||j
                         | j                  d |j                         | j                  ||j                         | j                  d|j                         y )N)r  rN   r   r  r  r  )r   r   r  r   r   r   r  s          r   test_attributes_old_constructorz0SyntaxErrorTests.test_attributes_old_constructorD  s    *#It4*.'&&%=#9#9:!5!56}778!5!56}778 2 23M$5$56r   c                     d}| j                  t        t        d|       d}| j                  t        t        d|       d}| j                  t        t        d|       y )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_constructorP  sM    )[)TB+)[)TB-)[)TBr   N)	r   r   r    r  r  r  r   r"  r%  r!   r   r   r  r    s#    X(t:

7
7Cr   r  c                       e Zd Zd Zy)TestInvalidExceptionMatcherc                    | j                  t              5  	 t        # d$ r Y nw xY w	 d d d        n# 1 sw Y   nxY w| j                  t              5  	 t        # t        df$ r Y nw xY w	 d d d        y # 1 sw Y   y xY w)Nr"  )r\   rX   rY   r+   s    r   'test_except_star_invalid_exception_typezCTestInvalidExceptionMatcher.test_except_star_invalid_exception_type\  s    y) 	   		 	 	 y) 	  # 		 	 	sF   3&3&3<A7AA*'A7)A**A77B N)r   r   r    r)  r!   r   r   r'  r'  [  s    r   r'  c                   N    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y)PEP626Testsc                    	  |        | j                  d       g }j                  }|r[|j                  }|j                  |j                  d n"|j                  |j                  j                  z
         |j                  }|r[| j                  t        |      |       y # t        $ r}|j                  }Y d }~d }~ww xY w)Nr<  )ri   r*   r   r   r   r  f_linenor   co_firstlinenor5   tuple)r   rZ  r  r  tlinesframes          r   lineno_after_raisezPEP626Tests.lineno_after_raisel  s    	-C II+,IIJJELL.u||::: 		A  	ux0  	!  A	!s   B! !	C *B;;C c                 .    d }| j                  |d       y )Nc                      ddz   y r  r!   r!   r   r   simplez:PEP626Tests.test_lineno_after_raise_simple.<locals>.simple  s    aCr   rN   r3  )r   r6  s     r   test_lineno_after_raise_simplez*PEP626Tests.test_lineno_after_raise_simple~  s    	 	*r   c                 .    d }| j                  |d       y )Nc                  (    	 ddz   y #  ddz   Y y xY wr  r!   r!   r   r   	in_exceptz@PEP626Tests.test_lineno_after_raise_in_except.<locals>.in_except  s    !!s    r   r7  )r   r;  s     r   !test_lineno_after_raise_in_exceptz-PEP626Tests.test_lineno_after_raise_in_except  s    	 		1-r   c                 .    d }| j                  |d       y )Nc                  <    	 ddz   y # t         $ r
} Y d } ~ y 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   r7  )r   r?  s     r   test_lineno_after_other_exceptz*PEP626Tests.test_lineno_after_other_except  s    	
 	a0r   c                 .    d }| j                  |d       y )Nc                  F    	 ddz   y # t         $ r} ddz   Y d } ~ y d } ~ ww xY wr  r)   r  s    r   in_named_exceptz@PEP626Tests.test_lineno_in_named_except.<locals>.in_named_except  s(    ! !s    	  r   r7  )r   rC  s     r   test_lineno_in_named_exceptz'PEP626Tests.test_lineno_in_named_except  s    	 	3r   c                 .    d }| j                  |d       y )Nc                      	 ddz   y # w xY wr  r!   r!   r   r   in_tryz.PEP626Tests.test_lineno_in_try.<locals>.in_try  s    !s    
r   r7  )r   rG  s     r   test_lineno_in_tryzPEP626Tests.test_lineno_in_try  s    	
 	*r   c                 .    d }| j                  |d       y )Nc                  &    	 	 ddz   y # ddz   w xY wr  r!   r!   r   r   in_finally_normalzDPEP626Tests.test_lineno_in_finally_normal.<locals>.in_finally_normal  s"    ! !s   r   r7  )r   rK  s     r   test_lineno_in_finally_normalz)PEP626Tests.test_lineno_in_finally_normal      	 	 115r   c                 .    d }| j                  |d       y )Nc                  .    	 ddz   ddz   y # ddz   w xY wr  r!   r!   r   r   in_finally_exceptzDPEP626Tests.test_lineno_in_finally_except.<locals>.in_finally_except  s&    !! !s    r   r7  )r   rP  s     r   test_lineno_in_finally_exceptz)PEP626Tests.test_lineno_in_finally_except  rM  r   c                 H     G d d      fd}| j                  |d       y )Nc                       e Zd Zd Zd Zy)0PEP626Tests.test_lineno_after_with.<locals>.Noopc                     | S r   r!   r+   s    r   r}  z:PEP626Tests.test_lineno_after_with.<locals>.Noop.__enter__  r~  r   c                      y r   r!   r$  s     r   r  z9PEP626Tests.test_lineno_after_with.<locals>.Noop.__exit__  s    r   Nr  r!   r   r   NooprT    s    r   rW  c                  J             5  ddz   	 d d d        y # 1 sw Y   y xY wr  r!   )rW  s   r   
after_withz6PEP626Tests.test_lineno_after_with.<locals>.after_with  s'     !  s   "r   r7  )r   rY  rW  s     @r   test_lineno_after_withz"PEP626Tests.test_lineno_after_with  s$    	 	
	 	
A.r   c                     d }| j                  |d       |j                  j                  d      |_        | j                  |d        y )Nc                      ddz   y r  r!   r!   r   r   rZ  z8PEP626Tests.test_missing_lineno_shows_as_none.<locals>.f  s	    aCr   rN   s   )co_linetable)r3  __code__r   r  s     r   !test_missing_lineno_shows_as_nonez-PEP626Tests.test_missing_lineno_shows_as_none  sA    	1%ZZ''5T'U
4(r   c                 J     G d d      fd}| j                  |dd       y )Nc                       e Zd Zd Zd Zy)CPEP626Tests.test_lineno_after_raise_in_with_exit.<locals>.ExitFailsc                     | S r   r!   r+   s    r   r}  zMPEP626Tests.test_lineno_after_raise_in_with_exit.<locals>.ExitFails.__enter__  r~  r   c                     t         r   r\  r$  s     r   r  zLPEP626Tests.test_lineno_after_raise_in_with_exit.<locals>.ExitFails.__exit__  s      r   Nr  r!   r   r   	ExitFailsrb    s    !r   re  c                  H             5  ddz   d d d        y # 1 sw Y   y xY wr  r!   )re  s   r   rY  zDPEP626Tests.test_lineno_after_raise_in_with_exit.<locals>.after_with  s$     !  s   !rN   r7  )r   rY  re  s     @r   $test_lineno_after_raise_in_with_exitz0PEP626Tests.test_lineno_after_raise_in_with_exit  s&    	! 	!	 	
Aq1r   N)r   r   r    r3  r8  r<  r@  rD  rH  rL  rQ  rZ  r_  rg  r!   r   r   r+  r+  j  s9    1$+.14+66
/)
2r   r+  __main__)+r  r|  r^   r  r  r  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.   r  r  r  r  r'  r+  r   r  r!   r   r   <module>ro     s(    	 
     / / / 5 1 7 !Y I 
+ +_+X&& _+D7+(X&& +(`&+(++ &+VJ6x(( J6XdCx(( dCN("3"3 k2(## k2Z zHMMO AF  Gs   D" "D,+D,