
    F\h                    @   S r SSKrSSKrSSKrSSKrSSKrSSKrSSKJ	r	  SSK
r
SSK
Jr  / SQrS>S jrS rS?S jrS>S	 jrS>S
 jrSrSr " S S5      r\" 5       rS r\\SSS4S jr\" 5       rS r\\SS4S jr\4SS.S jjrSSS.S jr\4S jrS@S jr SAS jr!S@S jr"SBS jr#S?S jr$S?S jr%S  r& " S! S"5      r'S# r(S$ r)S% r*S& r+S'r, " S( S)\-5      r.S* r/\R`                  " S+/ S,QS-S./S/9r1S0 r2S1r3S>S2 jr4 " S3 S45      r5 " S5 S65      r6S7r7S8r8S9r9S:r:S; r;S< r<S= r=g)Cz@Extract, format and print information about Python stack traces.    N)suppress)
ANSIColors)extract_stack
extract_tbformat_exceptionformat_exception_onlyformat_listformat_stack	format_tb	print_exc
format_excprint_exception
print_lastprint_stackprint_tbclear_framesFrameSummaryStackSummaryTracebackException
walk_stackwalk_tbc                     Uc  [         R                  n[        R                  U 5      R	                  5        H  n[        X!SS9  M     g)zuPrint the list of tuples as returned by extract_tb() or
extract_stack() as a formatted stack trace to the given file.N fileend)sysstderrr   	from_listformatprint)extracted_listr   items       /usr/lib/python3.13/traceback.py
print_listr%      s;     |zz&&~6==?d2& @    c                 H    [         R                  U 5      R                  5       $ )a  Format a list of tuples or FrameSummary objects for printing.

Given a list of tuples or FrameSummary objects as returned by
extract_tb() or extract_stack(), return a list of strings ready
for printing.

Each string in the resulting list corresponds to the item with the
same index in the argument list.  Each string ends in a newline;
the strings may contain internal newlines as well, for those items
whose source text line is not None.
)r   r   r    )r"   s    r$   r	   r	   !   s     !!.188::r&   c                 &    [        [        XS9US9  g)a  Print up to 'limit' stack trace entries from the traceback 'tb'.

If 'limit' is omitted or None, all entries are printed.  If 'file'
is omitted or None, the output goes to sys.stderr; otherwise
'file' should be an open file or file-like object with a write()
method.
limitr   N)r%   r   )tbr*   r   s      r$   r   r   3   s     z"*6r&   c                 0    [        XS9R                  5       $ )z5A shorthand for 'format_list(extract_tb(tb, limit))'.r)   )r   r    r,   r*   s     r$   r   r   =   s    b&--//r&   c                 <    [         R                  [        U 5      US9$ )a  
Return a StackSummary object representing a list of
pre-processed entries from traceback.

This is useful for alternate formatting of stack traces.  If
'limit' is omitted or None, all entries are extracted.  A
pre-processed stack trace entry is a FrameSummary object
containing attributes filename, lineno, name, and line
representing the information that is usually printed for a stack
trace.  The line is a string with leading and trailing
whitespace stripped; if the source is not available it is None.
r)   )r    _extract_from_extended_frame_gen_walk_tb_with_full_positionsr.   s     r$   r   r   A   s&     88$R( 9 7 7r&   zG
The above exception was the direct cause of the following exception:

zF
During handling of the above exception, another exception occurred:

c                       \ rS rSrS rSrg)	_Sentinel^   c                     g)Nz
<implicit> selfs    r$   __repr___Sentinel.__repr___   s    r&   r6   N)__name__
__module____qualname____firstlineno__r9   __static_attributes__r6   r&   r$   r3   r3   ^   s    r&   r3   c                     U[         L U[         L :w  a  [        S5      eXs=L a	  [         L aM  O  X4$ U bD  [        U [        5      (       a  X R                  4$ [        S[        U 5      R                   S35      egX4$ )Nz-Both or neither of value and tb must be givenzException expected for value, z foundNN)	_sentinel
ValueError
isinstanceBaseException__traceback__	TypeErrortyper;   )excvaluer,   s      r$   _parse_value_tbrK   d   s    i0HIIi 9 ?#}------<#Cy112&: ; ; 9r&   Tc                    UR                  SS5      n[        XU5      u  p[        [        U5      XUSS9nUR	                  XEUS9  g)a  Print exception up to 'limit' stack trace entries from 'tb' to 'file'.

This differs from print_tb() in the following ways: (1) if
traceback is not None, it prints a header "Traceback (most recent
call last):"; (2) it prints the exception type and value after the
stack trace; (3) if type is SyntaxError and value has the
appropriate format, it prints the line where the syntax error
occurred with a caret on the next line indicating the approximate
position of the error.
colorizeFTr*   compact)r   chainrM   N)getrK   r   rH   r!   )	rI   rJ   r,   r*   r   rP   kwargsrM   tes	            r$   r   r   s   sF     zz*e,HB/IE	DK%	NBHH$hH7r&   c                    [         R                  b  [         R                  O[         R                  n[        R                  " US9n[        U [        XS9$ )Nr+   )r*   r   rM   )r   r   
__stderr__	_colorizecan_colorizer   BUILTIN_EXCEPTION_LIMIT)rI   r   rM   s      r$   _print_exception_bltinrY      s:    /3::S^^D%%40H3&=D\\r&   c                    UR                  SS5      n[        XU5      u  p[        [        U5      XUSS9n[	        UR                  XFS95      $ )ab  Format a stack trace and the exception information.

The arguments have the same meaning as the corresponding arguments
to print_exception().  The return value is a list of strings, each
ending in a newline and some containing internal newlines.  When
these lines are concatenated and printed, exactly the same text is
printed as does print_exception().
rM   FTrN   rP   rM   )rQ   rK   r   rH   listr    )rI   rJ   r,   r*   rP   rR   rM   rS   s           r$   r   r      sL     zz*e,HB/IE	DK%	NB			9::r&   F)
show_groupc                   UR                  SS5      nU[        L a  U n[        [        U5      USSS9n[	        UR                  X$S95      $ )ak  Format the exception part of a traceback.

The return value is a list of strings, each ending in a newline.

The list contains the exception's message, which is
normally a single string; however, for :exc:`SyntaxError` exceptions, it
contains several lines that (when printed) display detailed information
about where the syntax error occurred. Following the message, the list
contains the exception's ``__notes__``.

When *show_group* is ``True``, and the exception is an instance of
:exc:`BaseExceptionGroup`, the nested exceptions are included as
well, recursively, with indentation relative to their nesting depth.
rM   FNT)rO   )r]   rM   )rQ   rB   r   rH   r\   r   )rI   rJ   r]   rR   rM   rS   s         r$   r   r      sN     zz*e,H		DKd	CB((J(RSSr&   insert_final_newlinerM   c                t   [        US5      nU(       a  SOSnU(       a~  Ub  U(       d(  [        R                   U  [        R                   U 3nU$ [        R                   U  [        R                   S[        R                   U [        R                   U 3n U$ Ub  U(       d  U  U 3nU$ U  SU U 3nU$ )N	exception
r   z: )_safe_stringr   BOLD_MAGENTARESETMAGENTA)etyperJ   r`   rM   valuestrend_charlines          r$   _format_final_exc_linerl      s    E;/H+tH= --.ugj6F6F5GzRD K !--.ugj6F6F5Gr*J\J\I]^f]ghrhxhxgy  {C  zD  ED K	 =WXJ'D K WBxj
3DKr&   c                 H     U" U 5      $ !   SU SUR                    S3s $ = f)N< z
() failed>)r;   )rJ   whatfuncs      r$   rd   rd      s1    4E{44&$--
33s   
 !c                 @    [        [        R                  " 5       XUS9  g)zVShorthand for 'print_exception(sys.exception(), limit=limit, file=file, chain=chain)'.r*   r   rP   N)r   r   rb   rs   s      r$   r   r      s    CMMO55Ir&   c                 Z    SR                  [        [        R                  " 5       XS95      $ )z%Like print_exc() but return a string.r   r*   rP   )joinr   r   rb   ru   s     r$   r   r      s    77#CMMO5NOOr&   c           	      :   [        [        S5      (       d   [        [        S5      (       d  [        S5      e[        [        S5      (       a  [        [        R                  XUS9  g[        [        R
                  [        R                  [        R                  XUS9  g)z]This is a shorthand for 'print_exception(sys.last_exc, limit=limit, file=file, chain=chain)'.last_exc	last_typezno last exceptionrs   N)hasattrr   rC   r   rx   ry   
last_valuelast_tracebackrs   s      r$   r   r      se    3
##GC,E,E,--sJEEJs~~s7I7I#e	=r&   c                 j    U c  [         R                  " 5       R                  n [        [	        XS9US9  g)zPrint a stack trace from its invocation point.

The optional 'f' argument can be used to specify an alternate
stack frame at which to start. The optional 'limit' and 'file'
arguments have the same meaning as for print_exception().
Nr)   r+   )r   	_getframef_backr%   r   )fr*   r   s      r$   r   r      s)     	yMMO""}Q,48r&   c                 j    U c  [         R                  " 5       R                  n [        [	        XS95      $ )z5Shorthand for 'format_list(extract_stack(f, limit))'.r)   )r   r~   r   r	   r   )r   r*   s     r$   r
   r
      s(    yMMO""}Q455r&   c                     U c  [         R                  " 5       R                  n [        R	                  [        U 5      US9nUR                  5         U$ )a[  Extract the raw traceback from the current stack frame.

The return value has the same format as for extract_tb().  The
optional 'f' and 'limit' arguments have the same meaning as for
print_stack().  Each item in the list is a quadruple (filename,
line number, function name, text), and the entries are in order
from oldest to newest stack frame.
r)   )r   r~   r   r   extractr   reverse)r   r*   stacks      r$   r   r      sA     	yMMO""  Ae <E	MMOLr&   c                     U b-   U R                   R                  5         U R                  n U b  M,  gg! [         a     Nf = f)zEClear all references to local variables in the frames of a traceback.N)tb_frameclearRuntimeErrortb_nextr,   s    r$   r   r   	  sB    
.	KK ZZ .  		s   2 
??c                       \ rS rSrSrSrSSSSSSS.S jrS rS	 rS
 r	S r
S rS r\S 5       r\S 5       r\S 5       rSrg)r   i  a  Information about a single frame from a traceback.

- :attr:`filename` The filename for the frame.
- :attr:`lineno` The line within filename for the frame that was
  active when the frame was captured.
- :attr:`name` The name of the function or method that was executing
  when the frame was captured.
- :attr:`line` The text from the linecache module for the
  of code that was running when the frame was captured.
- :attr:`locals` Either None if locals were not supplied, or a dict
  mapping the name to the repr() of the variable.
)
filenamelineno
end_linenocolno	end_colnoname_lines_lines_dedentedlocals_codeTN)lookup_liner   rk   r   r   r   c                ^   Xl         X l        Uc  UOUU l        Xl        Xl        X0l        U
R                  S5      U l        X`l        SU l	        U(       a  U R                    U(       a9  UR                  5        VVs0 s H  u  pU[        US[        S9_M     snnU l        gSU l        gs  snnf )ac  Construct a FrameSummary.

:param lookup_line: If True, `linecache` is consulted for the source
    code line. Otherwise, the line will be looked up when first needed.
:param locals: If supplied the frame locals, which will be captured as
    object representations.
:param line: If provided, use this instead of looking up the line in
    the linecache.
Nr   localrq   )r   r   r   r   r   r   rQ   r   r   r   rk   itemsrd   reprr   )r8   r   r   r   r   r   rk   r   r   r   rR   kvs                r$   __init__FrameSummary.__init__%  s     !$.$6&J
"	ZZ(
#II+1(& ,q'==&(7; 	 (s   ;B)c                    [        U[        5      (       ay  U R                  UR                  :H  =(       aY    U R                  UR                  :H  =(       a9    U R                  UR                  :H  =(       a    U R
                  UR
                  :H  $ [        U[        5      (       a1  U R                  U R                  U R                  U R                  4U:H  $ [        $ N)	rD   r   r   r   r   r   tuplerk   NotImplementedr8   others     r$   __eq__FrameSummary.__eq__?  s    e\**MMU^^3 0KK5<</0II+0 KK5<</1 eU##MM4;;		499ENNr&   c                 d    U R                   U R                  U R                  U R                  4U   $ r   )r   r   r   rk   )r8   poss     r$   __getitem__FrameSummary.__getitem__I  s&    t{{DIItyyA#FFr&   c                 p    [        U R                  U R                  U R                  U R                  /5      $ r   )iterr   r   r   rk   r7   s    r$   __iter__FrameSummary.__iter__L  s&    T]]DKKDIIFGGr&   c                 `    SR                  U R                  U R                  U R                  S9$ )Nz7<FrameSummary file {filename}, line {lineno} in {name}>)r   r   r   )r    r   r   r   r7   s    r$   r9   FrameSummary.__repr__O  s0    HOO]]4;;TYY P H 	Hr&   c                     g)N   r6   r7   s    r$   __len__FrameSummary.__len__S  s    r&   c                 *   U R                   Gc  U R                  b  U R                  b  / n[        U R                  U R                  S-   5       H  n[        R
                  " U R                  U5      R                  5       nU(       d\  U R                  bO  U R                  R                  S5      (       a/  [        R                  " U R                  U5      R                  5       nUR                  U5        M     SR                  U5      S-   U l         g g g g )N   rn   rc   )r   r   r   range	linecachegetliner   rstripr   
startswith_getline_from_codeappendrv   )r8   linesr   rk   s       r$   
_set_linesFrameSummary._set_linesV  s    KK'+ET__q-@A ((?FFH

 64==;S;STW;X;X$77

FKRRTDT" B ))E*T1DK , (  r&   c                 :    U R                  5         U R                  $ r   )r   r   r7   s    r$   _original_linesFrameSummary._original_linese  s     	{{r&   c                     U R                  5         U R                  c2  U R                  b%  [        R                  " U R                  5      U l        U R                  $ r   )r   r   r   textwrapdedentr7   s    r$   _dedented_linesFrameSummary._dedented_linesk  sD     	'DKK,C#+??4;;#?D ###r&   c                     U R                  5         U R                  c  g U R                  R                  S5      S   R                  5       $ )Nrc   r   )r   r   	partitionstripr7   s    r$   rk   FrameSummary.lines  s<    ;;{{$$T*1-3355r&   )
r   r   r   r   r   r   r   r   r   r   )r;   r<   r=   r>   __doc__	__slots__r   r   r   r   r9   r   r   propertyr   r   rk   r?   r6   r&   r$   r   r     s    II ?Cd44<4GHH2  
 $ $ 6 6r&   r   c              #      #    U c=  [         R                  " 5       R                  R                  R                  R                  n U b!  X R                  4v   U R                  n U b  M   gg7f)zWalk a stack yielding the frame and line number for each frame.

This will follow f.f_back from the given frame. If no frame is given, the
current stack is used. Usually used with StackSummary.extract.
N)r   r~   r   f_lineno)r   s    r$   r   r   |  sP      	yMMO""))0077
-mHH -s   A"A(&A(c              #   j   #    U b,  U R                   U R                  4v   U R                  n U b  M+  gg7f)zWalk a traceback yielding the frame and line number for each frame.

This will follow tb.tb_next (and thus is in the opposite order to
walk_stack). Usually used with StackSummary.extract.
N)r   	tb_linenor   r   s    r$   r   r     s/      .kk2<<''ZZ .s   -33c              #      #    U bt  [        U R                  R                  U R                  5      nUS   c"  U R                  U R                  4USS  -   4v   OU R                  U4v   U R
                  n U b  Ms  g g 7fNr   r   )_get_code_positionr   f_codetb_lastir   r   )r,   	positionss     r$   r1   r1     sr      .&r{{'9'92;;G	 Q<++/)AB-???++y((ZZ .s   A5A;9A;c                 v    US:  a  gU R                  5       n[        [        R                  " X!S-  S 5      5      $ )Nr   )NNNN   )co_positionsnext	itertoolsislice)codeinstruction_indexpositions_gens      r$   r   r     s8    1'%%'M	  Q0FMNNr&      c                   r    \ rS rSrSr\SSSS.S j5       r\SSSS.S j5       r\S	 5       rS
 r	S r
S rSrg)r   i  z?A list of FrameSummary objects, representing a stack of frames.NTFr*   lookup_linescapture_localsc                <   ^ U4S jnU R                  U" 5       X#US9$ )a  Create a StackSummary from a traceback or stack object.

:param frame_gen: A generator that yields (frame, lineno) tuples
    whose summaries are to be included in the stack.
:param limit: None to include all frames or the number of frames to
    include.
:param lookup_lines: If True, lookup lines for each frame immediately,
    otherwise lookup is deferred until the frame is rendered.
:param capture_locals: If True, the local variables from each frame will
    be captured as object representations into the FrameSummary.
c               3   6   >#    T H  u  pXS S S 44v   M     g 7fr   r6   )r   r   	frame_gens     r$   extended_frame_gen0StackSummary.extract.<locals>.extended_frame_gen  s$     &	$d333 's   r   )r0   )klassr   r*   r   r   r   s    `    r$   r   StackSummary.extract  s-    	4 55 ) 6 + 	+r&   c                   U[         L nUb  U(       a  [        [        SS 5      nUb  US:  a  SnUbV  U(       a  [        U5      nU[	        U5      U-
  S  nO2US:  a  [
        R                  " X5      nO[        R                  " X* S9nU " 5       n[        5       nU H  u  nu  ppUR                  nUR                  nUR                  nUR                  U5        [        R                  " XR                   5        U(       a  UR"                  nOS nUR%                  ['        XUSUXUUR                  S9	5        M     U H  n[        R(                  " U5        M     U(       a  U H  nUR*                    M     U$ )Ntracebacklimitr   )maxlenF)r   r   r   r   r   r   )rX   getattrr   r   lenr   r   collectionsdequesetr   co_filenameco_nameaddr   	lazycache	f_globalsf_localsr   r   
checkcacherk   )r   r   r*   r   r   builtin_limitresultfnamesr   r   r   r   r   cor   r   r   s                    r$   r0   -StackSummary._extract_from_extended_frame_gen  sS    !88=MC!148E UQY!),	%c)nu&<&=>	!%,,Y>	'--iG	9B5A5EB~~H::DJJx ++6::MMXt %h))(( :C$ H  *   r&   c           
          [        5       nU HI  n[        U[        5      (       a  UR                  U5        M+  Uu  pEpgUR                  [        XEXgS95        MK     U$ )zh
Create a StackSummary object from a supplied list of
FrameSummary objects or old-style list of tuples.
rk   )r   rD   r   r   )r   a_listr  framer   r   r   rk   s           r$   r   StackSummary.from_list  sR     E%..e$/4,$l8TMN  r&   c                 
  ^^^^^^^^^^^ UR                  SS5      m/ nUR                  nUR                  R                  S5      (       a  SnT(       a  UR                  SR	                  [
        R                  U[
        R                  [
        R                  UR                  [
        R                  [
        R                  UR                  [
        R                  5	      5        O5UR                  SR	                  XAR                  UR                  5      5        UR                  (       Ga  UR                  R                  5       (       Ga  UR                  b  UR                  c5  UR                  [        R                  " UR                   S5      S	-   5        GOWUR"                  R%                  5       nUS
   nXQR&                  UR                  -
     n[)        XaR                  5      n[)        XqR                  5      n	UR                  R%                  5       SUR&                  UR                  -
  S-    m[+        U5      [+        TS
   5      -
  n
[-        S
X-
  5      n[-        S
X-
  5      n	[/        TS
   US9m[/        TS   U	S9mS	R1                  T5      nX[+        U5      [+        TS   5      U	-
  -
   nSmSm[3        [4        5         [7        U5      mSSS5        U R9                  XTT5      m/ mS
[+        T5      S-
  1nS
mS
mSmSmT(       a  TR:                  mTR<                  mTR>                  S
:X  a  TU-  mTR@                  S
:X  a  TU-  m[/        TTR>                     TS9m[/        TTR@                     TS9mTRB                  mTRD                  mURG                  [I        TR>                  S-
  TR>                  S-   5      5        URG                  [I        TR@                  S-
  TR@                  S-   5      5        URK                  S5        URK                  [+        T5      5        UUUUUUUUUUU4S jn[M        U5      n[O        U5       HO  u  nnU(       a:  UXS-
     -
  nUS:X  a  U" US-
  5        OUS:  a  TR                  SUS-
   S35        U" U5        MQ     UR                  [        R                  " [        RP                  " SR1                  T5      5      SS 5      5        URR                  (       aL  [M        URR                  RU                  5       5       H%  u  nnUR                  SR	                  UUS95        M'     SR1                  U5      $ ! , (       d  f       GN= f)zFormat the lines for a single FrameSummary.

Returns a string representing one frame involved in the stack. This
gets called for every frame to be printed in the stack summary.
rM   Fz<stdin>-z<stdin>z(  File {}"{}"{}, line {}{}{}, in {}{}{}
z  File "{}", line {}, in {}
Nz    rc   r   r   )offset^r   c                   > TR                  TU    S-   5        T(       d  g[        TU    5      [        TU    R                  5       5      -
  n/ nU [        T5      S-
  :X  a  TO[        TU    5      n[	        U5       H  nXA:  d  U S:X  a  UT:  a  UR                  S5        M'  T(       a_  U TR
                  :  d  U TR
                  :X  a?  UT:  a9  U TR                  :  d  U TR                  :X  a  UT:  a  UR                  T5        M  UR                  T5        M     T(       Ga  TS   n/ n/ n[        R                  " [        R                  " XRSS9S	 S
9 GH  u  p[        U	5      n
US:X  a  UR                  [        R                  SR                  S U
 5       5      -   [        R                  -   5        UR                  [        R                  SR                  S U
 5       5      -   [        R                  -   5        M  US:X  a  UR                  [        R                  SR                  S U
 5       5      -   [        R                  -   5        UR                  [        R                  SR                  S U
 5       5      -   [        R                  -   5        GMF  UR                  SR                  S U
 5       5      5        UR                  SR                  S U
 5       5      5        GM     SR                  U5      nSR                  U5      nUTS'   TR                  US-   5        gTR                  SR                  U5      S-   5        g)z*output all_lines[lineno] along with caretsrc   Nr   r   ro   r  r   )	fillvaluec                     U S   $ Nr   r6   xs    r$   <lambda>HStackSummary.format_frame_summary.<locals>.output_line.<locals>.<lambda>  s      @A  BC  @Dr&   )keyr  c              3   *   #    U  H	  u  pUv   M     g 7fr   r6   .0char_s      r$   	<genexpr>IStackSummary.format_frame_summary.<locals>.output_line.<locals>.<genexpr>  s     YznycjcgZ^ny   c              3   *   #    U  H	  u  pUv   M     g 7fr   r6   r  r  carets      r$   r  r    s     [~r}fnfg\ar}r  ~c              3   *   #    U  H	  u  pUv   M     g 7fr   r6   r  s      r$   r  r    s     Tuit^e^bUYitr  c              3   *   #    U  H	  u  pUv   M     g 7fr   r6   r   s      r$   r  r    s     VymxaiabW\mxr  c              3   *   #    U  H	  u  pUv   M     g 7fr   r6   r  s      r$   r  r    s     CdXcWTDXcr  c              3   *   #    U  H	  u  pUv   M     g 7fr   r6   r   s      r$   r  r    s     Eh\gPXPQe\gr  )r   r   lstrip_display_widthr   left_end_linenoright_start_linenor   groupbyzip_longestr\   r   BOLD_REDrv   rf   RED)r   
num_spacescarets
num_caretscolrk   colorized_line_partscolorized_carets_partscolorgroupcaret_groupcolorized_linecolorized_carets	all_linesanchorsanchors_left_end_offsetanchors_right_start_offsetrM   dp_end_offsetdp_start_offsetprimary_charr  secondary_charshow_caretss                r$   output_line6StackSummary.format_frame_summary.<locals>.output_liney  s   MM)F"3d":;&!$Yv%6!7#i>O>V>V>X:Y!YJF28C	NQ<N2NTbclmsctTuJ$Z0+!o@U"MM#.$"W%<%<<#w'>'>>3JaCa"W%?%??#w'A'AAcLfFf #MM.9"MM,7  1    &bz/1,13.,5,=,=i>S>STXln>o  vD  -ELE*.u+K$| 4 ; ;J<O<ORTRYRYYznyYzRz<z  ~H  ~N  ~N  =N  !O 6 = =j>Q>QTVT[T[[~r}[~T~>~  BL  BR  BR  ?R  !S!&# 4 ; ;JNNRWWTuitTuMu<u  yC  yI  yI  =I  !J 6 = =jnnrwwVymxVyOy>y  }G  }M  }M  ?M  !N 4 ; ;BGGCdXcCd<d e 6 = =bggEh\gEh>h i -E *,1E)F+-773I+J(%3r
&6&=>bggfo&<=r&   z...<z lines>...
r   c                     gNTr6   r  s    r$   r  3StackSummary.format_frame_summary.<locals>.<lambda>  s    [_r&   z    {name} = {value}
)r   rJ   )+rQ   r   r   r   r    r   rg   rf   r   r   r   r   r   r   r   indentrk   r   
splitlinesr    _byte_offset_to_character_offsetr   maxr(  rv   r   	Exception(_extract_caret_anchors_from_line_segment_should_show_caretsleft_end_offsetright_start_offsetr)  r*  r@  rA  updater   discardsorted	enumerater   r   r   )r8   frame_summaryrR   rowr   all_lines_original
first_line	last_linestart_offset
end_offsetdedent_characterssegmentsignificant_linesrC  sig_lines_listir   linediffr   rJ   r:  r;  r<  r=  rM   r>  r?  r@  r  rA  rB  s                       @@@@@@@@@@@r$   format_frame_summary!StackSummary.format_frame_summary
  s    ::j%0 ))!!,,Z88 HJJBII&&$$&&!(($$&&!&&$$
  JJ6==..0B0BD E(((]-J-J-P-P-R-R##+''/ 

8??=+=+=vFMN &3%B%B%M%M%O"/2
./G/G-J^J^/^_	  @
L_L_`=iI`I`a
)99DDFH]--0D0DDqH	
 %(
Oc)A,6G$G!"1l&FG J$BC

 #11l"S .y}Z P ))I.!s7|s9R=?QT^?^/_` #i(FwOG )"66|QZ\cd &'I(:$;!*+'-.*"!$.5.E.E+181K1K. ..!3/<?/11Q62lB2 /=!'"9"9:CZ/+ 2@!'"<"<=F`2. $+#7#7L%,%;%;N%,,g5597;R;RUV;VW &,,g881<g>X>X[\>\]
 "))"-!))#i.90> 0>f "((9!:!*>!:IAv#)Nq5,A#A#q='
3%\"MMDAl*KL' "; 

OOHOOBGGFO$DfN_` %m&:&:&@&@&BCe

3::E:RS  D wws|e )(s   
U!!
U0c                 v  ^^^ [        [        [        5         SS KnUR	                  SR                  T5      5      nUR                  (       d
   S S S 5        gUR                  S   nS nUUU4S jn	U=UR                  S` =bQ  u  UR                  S` =b?  u     [        UR                  R                  UR                  5      (       a  UR                  nOt  UR                  S` =bb  u  UR                  S` =bP  u   [        UR                  5      S:X  a6  [        UR                  S   UR                  5      (       a  UR                  nO  Ub  U	" U5      (       a
   S S S 5        gS S S 5        U(       a  gTS   S T R!                  5       (       d  TS	   TS  R#                  5       (       a  gg! , (       d  f       NN= f)
Nr   rc   Fc                    > U R                   S:H  =(       aD    U R                  [        T5      :H  =(       a%    U R                  T:H  =(       a    U R                  T:H  $ r  )r   r   r   
col_offsetend_col_offset)rJ   r:  r[  rZ  s    r$   _spawns_full_line;StackSummary._should_show_carets.<locals>._spawns_full_line  sS    LLA% ;((C	N:;((L8; ,,
:	r&   )rJ   r6   r   Tr  )r   SyntaxErrorImportErrorastparserv   bodyReturnCallrD   rJ   rq   NameAssignr   targetsr'  r   )
r8   rZ  r[  r:  r;  rl  tree	statementrJ   rh  s
    ```      r$   rN   StackSummary._should_show_carets  sS   k;/99TYYy12D99	 0/
 		!IE 1SZZ1chhj1!)//"6"6AA ) 2 ZZ1chhjI--.!3"9#4#4Q#7BB ) 2  %6u%=%=3 0//4 Q<&--//9R=3M3T3T3V3V= 0/s%   7F*A-F*A	F*&F*:F**
F8c                 @   UR                  SS5      n/ nSnSnSnSnU  H  nU R                  XS9n	U	c  M  Ub3  XHR                  :w  d$  Ub!  XXR                  :w  d  Ub  XhR                  :w  aY  U[
        :  a)  U[
        -  nUR                  SU SUS:  a  S	OS
 S35        UR                  nUR                  nUR                  nSnUS-  nU[
        :  a  M  UR                  U	5        M     U[
        :  a)  U[
        -  nUR                  SU SUS:  a  S	OS
 S35        U$ )a  Format the stack ready for printing.

Returns a list of strings ready for printing.  Each string in the
resulting list corresponds to a single frame from the stack.
Each string ends in a newline; the strings may contain internal
newlines as well, for those items with source text lines.

For long sequences of the same frame and line, the first few
repetitions are shown, followed by a summary line stating the exact
number of further repetitions.
rM   FNr   rM   z  [Previous line repeated z
 more timer   sr   z]
)rQ   rb  r   r   r   _RECURSIVE_CUTOFFr   )
r8   rR   rM   r  	last_filerY  	last_namecountrU  formatted_frames
             r$   r    StackSummary.format  sZ    ::j%0			!M"777YO&!Y2H2H%H!Y2F2F%F!Y2D2D%D,,..EMM4UG <&+aisR8= *22	)00	)..	QJE((MM/*) ", $$&&EMM,UG 4#aisR05 r&   r6   )r;   r<   r=   r>   r   classmethodr   r0   r   rb  rN  r    r?   r6   r&   r$   r   r     sb    I+/d + +* DHe/ /b  $unB.r&   r   c                 \    U R                  S5      n[        US U R                  SSS95      $ )Nzutf-8replace)errors)encoder   decode)strr  as_utf8s      r$   rJ  rJ    s2    jj!Gww&&wy&ABBr&   _Anchors)r)  rO  r*  rP  r@  rA  r"  r  )defaultsc                 &  ^^^^^ SSK n UR                  SU  S35      n[        UR                  5      S:w  a  gU R                  5       mU4S jmU4S jmU4S jmU4S	 jmUUU4S
 jnSUU4S jjnUR                  S   nUUR                  S`=Gbm  u  nU=UR                  S` =b  u     U" UR                  5      u  pxU" XxS 5      u  pxUS-   n	U	[        TU   5      :  a}  UR                  R                  S-
  U:  d8  U	T" UR                  R                  S-
  UR                  R                  5      :  a(  TU   U	   =n
R                  5       (       d  U
S;  a  U	S-  n	[        XxXy5      $   =UR                  S` =b8  u     U" UR                  5      u  pU" XS 5      u  pU" USS9u  p[        XX5      $   UR                   S` =b7  u   U" UR"                  5      u  pU" XS 5      u  pU" USS9u  p[        XX5      $    g  g! [         a     gf = f)z
Given source code `segment` corresponding to a FrameSummary, determine:
    - for binary ops, the location of the binary op
    - for indexing and function calls, the location of the brackets.
`segment` is expected to be a valid Python expression.
r   Nz(
z
)r   c                 "   > [        TU    U5      $ )z%Get character index given byte offset)rJ  )r   r  r   s     r$   	normalize;_extract_caret_anchors_from_line_segment.<locals>.normalizeL  s    /fvFFr&   c                    > U [        T5      :  a<  U[        TU    5      :  a*  SnU S-  n U [        T5      :  a  U[        TU    5      :  a  M*  U [        T5      :  a  U[        TU    5      :  d   eX4$ )zkGets the next valid character index in `lines`, if
the current location is not valid. Handles empty lines.
r   r   )r   )r   r2  r   s     r$   next_valid_charA_extract_caret_anchors_from_line_segment.<locals>.next_valid_charP  sy     s5z!cSv-?&?CaKF s5z!cSv-?&? E
"sSv-?'???{r&   c                 (   > US-  nT" X5      u  pX4$ )z.Get the next valid character index in `lines`.r   r6   r   r2  r  s     r$   	increment;_extract_caret_anchors_from_line_segment.<locals>.incrementZ  s     q%f2{r&   c                 ,   > SnU S-  n T" X5      u  pX4$ )z6Get the next valid character at least on the next liner   r   r6   r  s     r$   nextline:_extract_caret_anchors_from_line_segment.<locals>.nextline`  s%    !%f2{r&   c                 t   >  TU    U   nUS;   a  T" X5      u  pOU" U5      (       d  T" X5      u  pO X4$ M7  )zIGet the next valid non-"\#" character that satisfies the `stop` predicate\#r6   )r   r2  stopchr  r   r  s       r$   increment_untilA_extract_caret_anchors_from_line_segment.<locals>.increment_untilg  sP    vs#BU{&v3"XX'4{ r&   c                 j   > U R                   S-
  nT" X R                  5      nU(       a  T" X#5      $ X#4$ )zGet the lineno/col position of the end of `expr`. If `force_valid` is True,
forces the position to be a valid character (e.g. if the position is beyond the
end of the line, move to the next line)
r   )r   rg  )exprforce_validr   r2  r  r  s       r$   setup_positionsA_extract_caret_anchors_from_line_segment.<locals>.setup_positionss  s7     1$ 3 34/:v+MMr&   r6   c                 D    U R                  5       (       + =(       a    U S:g  $ )N)isspacer  s    r$   r  :_extract_caret_anchors_from_line_segment.<locals>.<lambda>  s    QYY[Ie]^be]eIer&   r   r  c                     U S:H  $ )N[r6   r  s    r$   r  r        ]^be]er&   F)r  c                     U S:H  $ )N(r6   r  s    r$   r  r    r  r&   )T)rl  rm  rj  r   rn  rI  ExprBinOpleftrightr   rf  r  r  	SubscriptrJ   rp  rq   )r]  rl  rt  r  r  ru  r  r   r2  	right_colr  left_linenoleft_colright_linenor  r   r  r  r  s                 @@@@@r$   rM  rM  %  s#    * yy3wis+, 499~ EG
	N 	N 		!I
XX^^ SYY[ #2$))"<KF #2&?e"fKF !$aI!Cf$66 !JJ--1F:%	$**2C2Ca2GI^I^(__',V}Y'?!? H H J JeO!Q	 $FCC3 !4 %S]]_ -<DJJ,G)K,;KSe,f)K.=dPU.V+L#K<SS % XXZ -<DII,F)K,;KSe,f)K.=dPU.V+L#K<SS   k j c  s   H 
HHWFc                    ^ Uc  [        U 5      nU R                  5       (       a  U$ SSKm[        U4S jU SU  5       5      $ )zCalculate the extra amount of width space the given source
code segment might take if it were to be displayed on a fixed
width output device. Supports wide unicode characters and emojis.Nr   c              3   ^   >#    U  H"  nTR                  U5      [        ;   a  S OSv   M$     g7f)r   r   N)east_asian_width_WIDE_CHAR_SPECIFIERS)r  r  unicodedatas     r$   r  !_display_width.<locals>.<genexpr>  s0      !D ))$/3HHaO!s   *-)r   isasciir  sum)rk   r  r  s     @r$   r(  r(    sH    
 ~T ||~~ &M  r&   c                   *    \ rS rSrS rS rSS jrSrg)_ExceptionPrintContexti  c                 >    [        5       U l        SU l        SU l        g )Nr   F)r   seenexception_group_depth
need_closer7   s    r$   r   _ExceptionPrintContext.__init__  s    E	%&"r&   c                 &    SSU R                   -  -  $ )Nro   r   )r  r7   s    r$   rH  _ExceptionPrintContext.indent  s    a$44455r&   Nc              #     #    Uc  SnU R                  5       nU R                  (       a  X2S-   -  n[        U[        5      (       a  [        R                   " XS 5      v   g U H  n[        R                   " XCS 5      v   M     g 7f)N|ro   c                     grF  r6   r  s    r$   r  -_ExceptionPrintContext.emit.<locals>.<lambda>      Tr&   c                     grF  r6   r  s    r$   r  r    r  r&   )rH  r  rD   r  r   )r8   text_genmargin_char
indent_strtexts        r$   emit_ExceptionPrintContext.emit  sl     K[[]
%%++Jh$$//(8IJJ ood8IJJ !s   BB)r  r  r  r   )r;   r<   r=   r>   r   rH  r  r?   r6   r&   r$   r  r    s     
6Kr&   r  c            	           \ rS rSrSrSSSSSSSSS.S	 jr\S
 5       r\S 5       r	\S 5       r
S rS rS rSSS.S jrS rSSS.S jrSSS.S jrSrg)r   i  aR  An exception ready for rendering.

The traceback module captures enough attributes from the original exception
to this intermediary form to ensure that no references are held, while
still being able to fully print or format it.

max_group_width and max_group_depth control the formatting of exception
groups. The depth refers to the nesting level of the group, and the width
refers to the size of a single exception group's exceptions array. The
formatted output is truncated when either limit is exceeded.

Use `from_exception` to create TracebackException instances from exception
objects, or the constructor to create TracebackException instances from
individual components.

- :attr:`__cause__` A TracebackException of the original *__cause__*.
- :attr:`__context__` A TracebackException of the original *__context__*.
- :attr:`exceptions` For exception groups - a list of TracebackException
  instances for the nested *exceptions*.  ``None`` for other exceptions.
- :attr:`__suppress_context__` The *__suppress_context__* value from the
  original exception.
- :attr:`stack` A `StackSummary` representing the traceback.
- :attr:`exc_type` (deprecated) The class of the original traceback.
- :attr:`exc_type_str` String display of exc_type
- :attr:`filename` For syntax errors - the filename where the error
  occurred.
- :attr:`lineno` For syntax errors - the linenumber where the error
  occurred.
- :attr:`end_lineno` For syntax errors - the end linenumber where the error
  occurred. Can be `None` if not present.
- :attr:`text` For syntax errors - the text where the error
  occurred.
- :attr:`offset` For syntax errors - the offset into the text where the
  error occurred.
- :attr:`end_offset` For syntax errors - the end offset into the text where
  the error occurred. Can be `None` if not present.
- :attr:`msg` For syntax errors - the compiler error message.
NTF   
   )r*   r   r   rO   max_group_widthmax_group_depthsave_exc_type_seenc                   US LnUc
  [        5       nUR                  [        U5      5        Xl        Xl        [
        R                  [        U5      XEUS9U l        U
(       a  UOS U l	        [        US5      U l         [        USS 5      U l        SU l        US LU l        Ub#  UR$                  U l        UR(                  U l        OS U l        S U l        U(       a  [-        U[.        5      (       a  UR0                  U l        UR2                  nUb  [5        U5      OS U l        UR6                  nUb  [5        U5      OS U l        UR8                  U l        UR:                  U l        UR<                  U l        UR>                  U l        SU l        GO@U(       a]  [-        U[@        5      (       aH  [        USS 5      b:  [        USS 5      n[C        X#U5      nU(       a  U =R                  SU S	3-  sl        OU(       a  [-        U[D        [F        45      (       a  [        US
S 5      b  [        US
S 5      n[C        X#U5      nU(       a  U =R                  SU S	3-  sl        [-        U[D        5      (       a^  [        US
S 5      nUbN  U[H        RJ                  ;   a:  U(       a  U =R                  SU S	3-  sl        OU =R                  SU S	3-  sl        U(       a  U RM                  5         Ub  URN                  OSU l'        U(       GdK  X4/nU(       Ga>  URQ                  5       u  nnUbi  URR                  b\  [        URR                  5      U;  aC  [U        [W        URR                  5      URR                  URR                  RX                  UUUUU	US9	nOS nU(       a(  US L =(       a    US L=(       a    URN                  (       + nOSnUbp  URZ                  bc  U(       a\  [        URZ                  5      U;  aC  [U        [W        URZ                  5      URZ                  URZ                  RX                  UUUUU	US9	nOS nUb`  []        U[^        5      (       aK  / nUR`                   H8  n[U        [W        U5      UURX                  UUUUU	US9	nURc                  U5        M:     OS nUUl)        UUl-        UUl0        U(       a'  URc                  URR                  URR                  45        U(       a'  URc                  URZ                  URZ                  45        U(       a/  URe                  [g        UR`                  UR`                  5      5        U(       a  GM=  g g g ! [         a%  nS[        US[        5       3/U l         S nAGNS nAff = f)Nr   rb   	__notes__z!Ignored error getting __notes__: FT	name_fromz. Did you mean: 'z'?r   z Or did you forget to import 'z. Did you forget to import ')r*   r   r   r  r  r  )4r   r   idr  r  r   r0   r1   r   	_exc_typerd   _strr   r  rL  r   _is_syntax_error_have_exc_typer=   exc_type_qualnamer<   exc_type_module
issubclassrj  r   r   r  r   r  r  r[  msgrk  _compute_suggestion_error	NameErrorAttributeErrorr   stdlib_module_names_load_lines__suppress_context__pop	__cause__r   rH   rF   __context__rD   BaseExceptionGroup
exceptionsr   extendzip)r8   exc_type	exc_valueexc_tracebackr*   r   r   rO   r  r  r  r  is_recursive_callelnoend_lno
wrong_name
suggestionqueuerS   causeneed_contextcontextr  rI   texcs                             r$   r   TracebackException.__init__  s    "-=EE		"Y- ..!BB(7) C +

 &3 !K8		Z$YTBDN
 !&&d2%-%:%:D"#+#6#6D %)D"#'D 
8[99%..DM""C&)o#c(4DK**G.5.Ac'ltDO!DI#**DK'22DO }}DH$(D!*X{;;	;5A K>J29ZXJ		0B??	*X	>/JKK	640< FD9J29ZXJ		0B??	(I..$Y=
)jC<S<S.S!		'Ej\QS%TT			'CJ<r%RR	.7.CI** 	!
 !&'E		AMakk&=1;;u4.Q[[)11#%1'5(7(7#	%E !E$)TM %?$%TM%?()(>(>$> ! $(LMamm&?$AMM):%)G0Q]]+33#%1'5(7(7#	%G #G=Z3E%F%F!#J ||1 I--"')5+9,;,;"'	 ) #))$/  , "&J$!( *LL",,!<=LL"..!--!@ALLR]]ALL!AB % !g  	Z3LKQU4V3WXZDNN	Zs   =U 
U?U::U?c                 B    U " [        U5      XR                  /UQ70 UD6$ )z.Create a TracebackException from an exception.)rH   rF   )clsrI   argsrR   s       r$   from_exception!TracebackException.from_exception  s%     49c#4#4FtFvFFr&   c                 N    [         R                  " S[        SS9  U R                  $ )Nz-Deprecated in 3.13. Use exc_type_str instead.r   )
stacklevel)warningswarnDeprecationWarningr  r7   s    r$   r  TracebackException.exc_type  s     E(Q	8~~r&   c                     U R                   (       d  g U R                  nU R                  nUS;  a  [        U[        5      (       d  SnUS-   U-   nU$ )N)__main__builtinsz	<unknown>.)r  r  r  rD   r  )r8   stypesmods      r$   exc_type_strTracebackException.exc_type_str  sR    ""&&##//dC(("3J&Er&   c                 B    U R                    H  nUR                    M     g)z7Private API. force all lines in the stack to be loaded.N)r   rk   )r8   r  s     r$   r  TracebackException._load_lines  s    ZZEJJ  r&   c                 j    [        U[        5      (       a  U R                  UR                  :H  $ [        $ r   )rD   r   __dict__r   r   s     r$   r   TracebackException.__eq__  s)    e/00==ENN22r&   c                     U R                   $ r   )r  r7   s    r$   __str__TracebackException.__str__  s    yyr&   r   )r]   _depthc          	   +   n  #    UR                  SS5      nSU-  S-  nU R                  (       d  U[        SU R                  US9-   v   gU R                  nU R
                  (       db  US:  aE  [        X`R                  SUS9R                  S	5      nU Vs/ s H
  nXX-   S	-   PM     sn Sh  vN   OA[        X`R                  US9v   O*U R                  XdS9 Vs/ s H  oU-   PM	     sn Sh  vN   [        U R                  [        R                  R                  5      (       at  [        U R                  [        [        45      (       dO  U R                   H>  n	[        U	S
5      n	U	R                  S	5       Vs/ s H
  oU-   S	-   PM     sn Sh  vN   M@     O:U R                  b-  USR!                  [        U R                  S["        S95      -   v   U R$                  (       a7  U(       a/  U R$                   H  n
U
R'                  XS-   US9 Sh  vN   M      gggs  snf  GNvs  snf  GN<s  snf  N N"7f)am  Format the exception part of the traceback.

The return value is a generator of strings, each ending in a newline.

Generator yields the exception message.
For :exc:`SyntaxError` exceptions, it
also yields (before the exception message)
several lines that (when printed)
display detailed information about where the syntax error occurred.
Following the message, generator also yields
all the exception's ``__notes__``.

When *show_group* is ``True``, and the exception is an instance of
:exc:`BaseExceptionGroup`, the nested exceptions are included as
well, recursively, with indentation relative to their nesting depth.
rM   Fr   ro   Nrx  r   r_   rc   notez{}
r  r   r   )r]   r  rM   )rQ   r  rl   r  r  r  split_format_syntax_errorrD   r  r   abcSequencer  bytesrd   r    r   r  r   )r8   r]   r  rR   rM   rH  r  	formattedlr   exs              r$   r   (TracebackException.format_exception_only  s    " ::j%0Vc!""1$		HUUU!!$$z29958%+ 
 '& J%&  
 -UIIQQ,0,E,Ee,E,_`,_q
,_``` t~~{'?'?@@t~~U|<<#D&17;zz$7GH7G!QJ-7GHHH ' ^^'6==dnnkX\)]^^^??zoo33zYZRZem3nnn &  *?'  a` IH osn   BH5H%H5+H!,-H5H$'H5-H).B
H58H,	H5H1B H5H3H5$H5,H53H5c           	   +     #    UR                  SS5      nSnU R                  b  U(       an  SR                  [        R                  U R
                  =(       d    S[        R                  [        R                  U R                  [        R                  5      v   OZSR                  U R
                  =(       d    SU R                  5      v   O(U R
                  b  SR                  U R
                  5      nU R                  n[        U[        5      (       Ga=  UR                  S	5      nUR                  S
5      n[        U5      [        U5      -
  nU R                  c  SR                  U5      v   GO[        U R                  [        5      (       Ga  U R                  n	U R                  U R                  :X  a>  [        U R                   [        5      (       a  U R                   S:w  a  U R                   OU	n
O[        U5      S-   n
U R                  (       a'  U	[        U R                  5      :  a  [        U5      S-   n	U R                  (       a'  U
[        U R                  5      :  a  [        U5      S-   n
X:  d  U
S:  a  U	S-   n
U	S-
  U-
  nU
S-
  U-
  nSnUS:  a  S USU  5       nS=pU(       aQ  USU [        R"                  -   X{U -   [        R                  -   X|S -   n[        R"                  n[        R                  nSR                  U5      v   SR                  SR%                  U5      USX-
  -  U5      v   OSR                  U5      v   U R&                  =(       d    SnU(       aR  SR                  [        R(                  U[        R                  [        R                  U[        R                  U5      v   gSR                  UUU5      v   g7f)z0Format SyntaxError exceptions (internal helper).rM   Fr   Nz  File {}"{}"{}, line {}{}{}
z<string>z  File "{}", line {}
z ({})rc   z 
z    {}
r   r   ro   c              3   R   #    U  H  oR                  5       (       a  UOS v   M     g7f)ro   Nr  )r  cs     r$   r  :TracebackException._format_syntax_error.<locals>.<genexpr>2  s     !U}!		1#<}s   %'z    {}{}{}{}
r  z<no detail available>z{}{}{}: {}{}{}{}
z	{}: {}{}
)rQ   r   r    r   rg   r   rf   r  rD   r  r   r'  r   r  intr   r[  r-  rv   r  re   )r8   r  rR   rM   filename_suffixr  rtextltextspacesr  r[  r   r   
caretspacestart_color	end_colorr  s                    r$   r"  'TracebackException._format_syntax_error  s?     ::j%0;;"6==&&MM/Z$$&&KK$$  /55MM/Z> >]]&%nnT]];OyydC   KK%ELL)EZ#e*,F{{" ''..DKK--;;$//1 't<< $1 4 
 $  "%UaJ99#dii.!8 Z!^F99c$))n!<!$UaJ':>!'!J 
V+&NV3	 
A:!UuVe}!UJ.00K "&5M&//027i2HIKUK[K[\!*-. 
 '1&9&9$.$4$4	$++E22*11
+#	 12!	  %++E22hh11&--''  ""  ! ! %%eS/BBs   OO)rP   _ctxc          	   +   Z  #    UR                  SS5      nUc
  [        5       n/ nU nU(       az  U(       ar  UR                  b  [        nUR                  nO5UR                  b$  UR
                  (       d  [        nUR                  nOSnSnUR                  Xv45        UnU(       a  Mr  OUR                  SU45        [        U5       GHD  u  pU	b  UR                  U	5       Sh  vN   UR                  c  UR                  (       aI  UR                  S5       Sh  vN   UR                  UR                  R                  US95       Sh  vN   UR                  UR                  US95       Sh  vN   M  UR                  U R                  :  a)  UR                  SU R                   S35       Sh  vN   M  UR                  S:H  n
U
(       a  U=R                  S	-  sl        UR                  (       aQ  UR                  S
U
(       a  SOSS9 Sh  vN   UR                  UR                  R                  US95       Sh  vN   UR                  UR                  US95       Sh  vN   [!        UR                  5      nXR"                  ::  a  UnOU R"                  S	-   nSUl        ['        U5       GH-  nXS	-
  :H  nU(       a  SUl        U R"                  b  XR"                  :  nOSnU(       d  US	-    OSnUR)                  5       US:X  a  SOS-   SU S3-   v   U=R                  S	-  sl        U(       d&  UR                  U   R                  XUS9 Sh  vN   O8XR"                  -
  nUS	:  a  SOSnUR                  SU SU S35       Sh  vN   U(       a-  UR$                  (       a  UR)                  5       S-   v   SUl        U=R                  S	-  sl        GM0     U
(       d  GM+  UR                  S	:X  d   eSUl        GMG     g GN- GN GN GN GNi GN GN GN N N7f)a  Format the exception.

If chain is not *True*, *__cause__* and *__context__* will not be formatted.

The return value is a generator of strings, each ending in a newline and
some containing internal newlines. `print_exception` is a wrapper around
this method which just prints the lines to a file.

The message indicating which exception occurred is always the last
string in the output.
rM   FNz#Traceback (most recent call last):
rx  z... (max_group_depth is z)
r   r   z3Exception Group Traceback (most recent call last):
+)r  Tz...z+-z  z+---------------- z ----------------
)rP   r7  rM   ry  r   zand z more exceptionrc   z&+------------------------------------
)rQ   r  r  _cause_messager  r  _context_messager   reversedr  r  r   r    r   r  r  r   r  r  r   rH  )r8   rP   r7  rR   rM   outputrI   chained_msgchained_excr  is_toplevelnum_excsnr`  rx   	truncatedtitle	remainingplurals                      r$   r    TracebackException.formatS  s     ::j%0<)+D==,"0K"%--Koo222"2K"%//K"&K"&K{01! # MM4+& (HC99S>))~~%99#yy)OPPP#yy)9)98)9)LMMM99S%>%>%>%QRRR++d.B.BB99.t/C/C.DCHJ J J  $99Q>..!3.99#yyN-8cd  )  D D D  $yy)9)98)9)LMMM99S%>%>%>%QRRRs~~.333 A,,q0A"'qA !qSH*.++7%&*>*>%>	$)	,5qse5E;;=$%qDDd4/w6IJK L ..!3.$#&>>!#4#;#;%]e#;#fff$,/C/C$C	(1A2#'99"9+_VHBG$I I I  DOO#{{}H I J*/..!3..7 ": ;55:::12D.} )) QMRJD NR. gIs   B"P+&<P+"P#6P+P/P+	P
%P+/P0AP+2P3AP+P/P+P!%P+'P$(C2P+P'8P+P)AP+0 P+P+P+P+P+P+!P+$P+'P+)P+)r   rP   c                    UR                  SS5      nUc  [        R                  nU R                  X$S9 H  n[	        XQSS9  M     g)z7Print the result of self.format(chain=chain) to 'file'.rM   FNr[   r   r   )rQ   r   r   r    r!   )r8   r   rP   rR   rM   rk   s         r$   r!   TracebackException.print  s@    ::j%0<::DKKeK?D$r* @r&   )r  r  r  r  r  r  r   r[  r  r  r   r   r  r  r  r  r   r  )r;   r<   r=   r>   r   r   r  r  r   r  r  r  r   r  r   r"  r    r!   r?   r6   r&   r$   r   r     s    %N EIeU$dOCb G G  
 	 	

 38 4olYCv # b3J ! + +r&   r   i  (   r   r   c                 j    X:X  a  gU R                  5       UR                  5       :X  a  [        $ [        $ )Nr   )lower
_CASE_COST
_MOVE_COST)ch_ach_bs     r$   _substitution_costrQ    s*    |zz|tzz|#r&   c           	      F   Ub  [        U[        5      (       d  g [        U [        5      (       a  U R                  n  [	        U5      n[        U Vs/ s H  n[        U[        5      (       d  M  UPM     sn5      nUS S S:g  nU(       a[  UbX  UR                  b  UR                  nUR                  b  M  UR                  nSUR                  ;   a  UR                  S   UL a  SnU(       a  U Vs/ s H  oUS S S:w  d  M  UPM     nnGO[        U [        5      (       a{   [!        U R"                  5      n [	        U5      n[        U Vs/ s H  n[        U[        5      (       d  M  UPM     sn5      nUS S S:w  a  U Vs/ s H  oUS S S:w  d  M  UPM     nnO[        U [$        5      (       d   eUc  g UR                  b  UR                  nUR                  b  M  UR                  n[        UR                  5      [        UR&                  5      -   [        UR(                  5      -   nU Vs/ s H  n[        U[        5      (       d  M  UPM     nnSUR                  ;   a'  UR                  S   n	 [+        X5      n
U
(       a  SU 3$  SS KnUR/                  XB5      $ ! [
         aU    [        UR                  R                  R                  5       5      [        UR                  R                  5       5      -   n GNf = fs  snf s  snf ! [         a     g f = f! [
         a'    [        UR                  R                  5       5      n GNf = fs  snf s  snf ! [         a     g f = fs  snf ! [         a    Sn
 GN f = f! [         a     Of = f[1        U5      [2        :  a  g [1        U5      nU[4        :  a  g UnS nU H[  nX:X  a  M
  [1        U5      U-   S-   [6        -  S-  n[9        UUS-
  5      n[;        X/U5      nUU:  a  MH  U(       a  UU:  d  MW  UnUnM]     U$ )	Nr   r  r8   Fzself.r   r      )rD   r  r  objdirrG   r\   	__class__r  keysrS  r   r   r   rL  rk  
__import__r   r  r   
f_builtinsrz   _suggestions_generate_suggestionsr   _MAX_CANDIDATE_ITEMS_MAX_STRING_SIZErN  min_levenshtein_distance)r  r,   r  rT  dr  hide_underscoredr  modr8   has_wrong_namerZ  wrong_name_lenbest_distancer  possible_namemax_distancecurrent_distances                     r$   r  r    s   J!<!<)^,,mm	TH 1;1a
1c(:1;<A *2A# 5BNjj,B jj,U^^+v0F#0M',$ !21rUc\Q2 
I{	+	+
	Y^^,C.H 1;1a
1c(:1;<A"1~$ !21rUc\Q2 )Y////:jj$B jj$ 5??#$5##$% 	

 01Z3/Q0 U^^#>>&)D'!(!: zl++A 11!@@s  T//4467$s||?P?P?R:SST; 3 		  .**,-.;2 		 1  '!&'   1v$$_N(("MJ&M*^;a?:MQRR<):;0LYl*-=&J,M  s   J  	L L.L4?L 5;L 0L LL  M 6L 	M 
M'M-M MMM .M*M*3M/ N  AK?;L >K??L 
LL-M	M MM 
M'&M'/M?>M?
NNc           	         X:X  a  gSnXS  (       a6  XS  (       a-  X   X   :X  a#  US-  nXS  (       a  XS  (       a  X   X   :X  a  M#  XS  n XS  nSnU S U=(       d    S  (       a`  US U=(       d    S  (       aM  XS-
     XS-
     :X  a=  US-  nU S U=(       d    S  (       a%  US U=(       d    S  (       a  XS-
     XS-
     :X  a  M=  U S U=(       d    S  n US U=(       d    S  nU (       a  U(       d  [         [        U 5      [        U5      -   -  $ [        U 5      [        :  d  [        U5      [        :  a  US-   $ [        U5      [        U 5      :  a  Xp[        U5      [        U 5      -
  [         -  U:  a  US-   $ [        [	        [         [         [        U 5      S-   -  [         5      5      nSn[	        [        U5      5       H  nX   nU[         -  =p[
        R                  n
[	        [        U 5      5       HB  nU	[        XU   5      -   nX[   n	[        Xi5      [         -   n[        X5      nXeU'   Xj:  d  M@  Un
MD     X:  d  M  US-   s  $    U$ r   )	rN  r   r]  r\   r   r   maxsizerQ  r^  )abmax_costprepostrV  r  bindexbchardistanceminimumindex
substituteinsert_deletes                 r$   r_  r_  ,  s1    	v C
D'ag!&AF"2q D'ag!&AF"2	$A	$AD
MT\T
q$,$/A1fI64J	 MT\T
q$,$/A1fI64J	-4<4A	-4<4AASVc!f_--
1v  CF-=$=!| 1vA1 	AQ:%0!|
 uZs1vz!:JG
HCFA-	"Z//++3q6]E!$6uh$GGJzH  1J>M3F  J  # a<)  * Mr&   r   rA   )NNTrF  )NNN)>r   collections.abcr   r   r   r   r   r
  
contextlibr   rV   r   __all__r%   r	   r   r   r   r:  r;  r3   rB   rK   r   objectrX   rY   r   r   rl   r  rd   r   r   r   r   r
   r   r   r   r   r   r1   r   rz  r\   r   rJ  
namedtupler  rM  r  r(  r  r   r\  r]  rN  rM  rQ  r  r_  r6   r&   r$   <module>r|     s   F    
      $';$707*& 
& 
  K	 #,	T8$ !( ] $-$;  )2 T T0 BFPU   $' 4JP	= 	96 e6 e6P
O  d4 dNC
 !! 3ZPd  *K K.Y+ Y+x   

Zz:r&   