
    Dgdk                        d dl Z d dlZd dlmZmZmZ eZe j        	                    dd          Z
ej        d          dk    rd dlmZ nd dlmZ d dlZ G d de          Z G d	 d
e          Z G d de          Z G d de          Z eddd          Z G d de          Z G d de          Z G d d          Z G d de          Z G d de          Z G d de          Z G d de          Z G d  d!e          Z G d" d#e          Z G d$ d%e          Z  G d& d'e          Z!i Z"d,d)Z#d,d*Z$d-d+Z%dS ).    N)
CO_VARARGSCO_VARKEYWORDSisclassreprreprlib   )format_exception_onlyc                   ^    e Zd ZdZd Zd Zd Zed             Zed             Z	d Z
dd	Zd
S )Codez$ wrapper around Python code objects c                    t          |d          st          j                            |          }	 |j        | _        |j        dz
  | _        |j        | _	        n # t          $ r t          d|          w xY w|| _        d S )Nco_filename   znot a code object: )hasattrpycode
getrawcoder   filenameco_firstlinenofirstlinenoco_namenameAttributeError	TypeErrorraw)selfrawcodes     B/var/www/sysmax/venv/lib/python3.11/site-packages/py/_code/code.py__init__zCode.__init__   s    w.. 	2g((11G	B#/DM&59DDII 	B 	B 	B)ww@AAA	Bs   'A A6c                 "    | j         |j         k    S N)r   r   others     r   __eq__zCode.__eq__   s    x59$$    c                     | |k     S r     r!   s     r   __ne__zCode.__ne__!   s    5=  r$   c                     t           j                            | j        j                  }|                                s| j        j        }|S )zs return a path object pointing to source code (note that it
        might not point to an actually existing file). )r   pathlocalr   r   check)r   ps     r   r)   z	Code.path$   s=     GMM$(.//wwyy 	% $Ar$   c                 L    ddl m} |                    | j                  \  }}|S )zM return a py.code.Source object for the full source file of the code
        r   )source)py._coder.   
findsourcer   )r   r.   full_s       r   
fullsourcezCode.fullsource0   s4     	$#######DH--ar$   c                 J    t           j                            | j                  S )zJ return a py.code.Source object for the code object's source only
        )r   r   Sourcer   r   s    r   r.   zCode.source8   s     w~~dh'''r$   Fc                     | j         }|j        }|r$||j        t          z  z  }||j        t          z  z  }|j        d|         S )z return a tuple with the argument names for the code object

            if 'var' is set True also return the names of the variable and
            keyword arguments when present
        N)r   co_argcountco_flagsr   r   co_varnames)r   varr   argcounts       r   getargszCode.getargs>   sM     h? 	6z11H~55Hyy))r$   NF)__name__
__module____qualname____doc__r   r#   r'   propertyr)   r3   r.   r=   r&   r$   r   r   r      s        ..	 	 	% % %! ! ! 	 	 X	   X( ( (* * * * * *r$   r   c                   N    e Zd ZdZd Zed             Zd Zd Zd Z	d Z
dd	Zd
S )FramezgWrapper around a Python frame holding f_locals and f_globals
    in which expressions can be evaluated.c                     |j         dz
  | _        |j        | _        |j        | _        || _        t
          j                            |j                  | _        d S Nr   )	f_linenolineno	f_globalsf_localsr   r   r   r   f_code)r   frames     r   r   zFrame.__init__P   sD    nq(GLL..			r$   c                     | j         j        t          j                             d          S | j         j                            | j                  S )z statement this frame is at N )r   r3   r   r5   getstatementrI   r6   s    r   	statementzFrame.statementW   s>     9'7>>"%%%y#00===r$   c                     | j                                         }|                    |           t          || j        |          S )z evaluate 'code' in the frame

            'vars' are optional additional local variables

            returns the result of the evaluation
        )rK   copyupdateevalrJ   r   r   varsrK   s       r   rU   z
Frame.eval^   s=     =%%''D$.(333r$   c                     | j                                         }|                    |           t          j                            || j        |           dS )z^ exec 'code' in the frame

            'vars' are optiona; additional local variables
        N)rK   rS   rT   r   builtinexec_rJ   rV   s       r   rZ   zFrame.exec_i   sK    
 =%%''

t~x88888r$   c                 @    t           j                            |          S )zL return a 'safe' (non-recursive, one-line) string repr for 'object'
        r   iosafereprr   objects     r   r   z
Frame.reprr   s     u~~f%%%r$   c                     |S r    r&   r_   s     r   is_truezFrame.is_truew   s    r$   Fc                     g }| j                             |          D ]5}	 |                    || j        |         f           &# t          $ r Y 2w xY w|S )z return a list of tuples (name, value) for all arguments

            if 'var' is set True also include the variable and keyword
            arguments when present
        )r   r=   appendrK   KeyError)r   r;   retvalargs       r   r=   zFrame.getargsz   ss     9$$S)) 	 	CsDM#$678888   s   "A
AANr>   )r?   r@   rA   rB   r   rC   rQ   rU   rZ   r   rb   r=   r&   r$   r   rE   rE   L   s        . ./ / / > > X>	4 	4 	49 9 9& & &
       r$   rE   c                       e Zd ZdZdZdZd Zd Zed             Z	ed             Z
d Zed             Zed	             Zd
 Z eeddd          Zd Zd ZddZ ee          Zd Zd Zd Z eeddd          ZdS )TracebackEntryz a single entry in a traceback Nc                 2    || _         |j        dz
  | _        d S rG   )	_rawentry	tb_linenorI   )r   rawentrys     r   r   zTracebackEntry.__init__   s    !(1,r$   c                      |dv sJ || _         d S )Nshortlong)_repr_style)r   modes     r   set_repr_stylezTracebackEntry.set_repr_style   s"    (((((r$   c                 T    t           j                            | j        j                  S r    )r   r   rE   rk   tb_framer6   s    r   rM   zTracebackEntry.frame   s    w}}T^4555r$   c                 4    | j         | j        j        j        z
  S r    )rI   rM   r   r   r6   s    r   rellinezTracebackEntry.relline   s    {TZ_888r$   c                 >    d| j         j        j        | j        dz   fz  S )Nz<TracebackEntry %s:%d>r   )rM   r   r)   rI   r6   s    r   __repr__zTracebackEntry.__repr__   s    '4:?+?Q*OOOr$   c                 X    | j         j        j        }|                    | j                  S )z1 py.code.Source object for the current statement )rM   r   r3   rP   rI   )r   r.   s     r   rQ   zTracebackEntry.statement   s&     +""4;///r$   c                 $    | j         j        j        S )z path to the source code )rM   r   r)   r6   s    r   r)   zTracebackEntry.path   s     z##r$   c                     | j         j        S r    )rM   rK   r6   s    r   	getlocalszTracebackEntry.getlocals   s    z""r$   zlocals of underlaying framec                    | j         {t          | j                                                  }t          j                            || j        d          }t          |t                    st          d|          || _         | j         S )ztReinterpret the failing statement and returns a detailed information
           about what operations are performed.NT)should_failzinterpret returned non-string )
exprinfostrrQ   stripr   r   _reinterpretrM   
isinstancer   )r   r.   xs      r   reinterpretzTracebackEntry.reinterpret   s|     = ((..00F$$VTZT$JJAa%% Kiaa IJJJDM}r$   c                 @    t          | j        j        j        d          S Nr   )maxrM   r   r   r6   s    r   getfirstlinesourcez!TracebackEntry.getfirstlinesource   s    4:?.222r$   c                 F   ddl m} | j        j        j        }|dS dx}}|)| j        j        j        }||                    |d          }|                                 }	  || j        ||          \  }}}||||<   n# t          $ r | j        dz   }Y nw xY w|||         S )z return failing source code. r   )getstatementrange_astN)astnoder   )
py._code.sourcer   rM   r   r3   r)   getr   rI   SyntaxError)	r   astcacher   r.   keyr   startr2   ends	            r   	getsourcezTracebackEntry.getsource   s     	:99999+>4g*/&C",,sD11''))	(33DK<CE E EOGQ
  '	  	" 	" 	"+/CCC	"
 eCi  s    A? ?BBc                     	 | j         j        d         S # t          $ r( 	 | j         j        d         cY S # t          $ r Y Y dS w xY ww xY w)z return True if the current frame has a var __tracebackhide__
            resolving to True

            mostly for internal use
        __tracebackhide__F)rM   rK   re   rJ   r6   s    r   ishiddenzTracebackEntry.ishidden   ss    	:&':;; 	 	 	z+,?@@@@   uuu	s(    
A3A
AAAAc                     	 t          | j                  }n# t          j        j        $ r d}Y nw xY w| j        j        j        }	 t          | j                  	                                }n# t          $ r   d}Y nxY wd|| j        dz   ||fz  S )N???z  File %r:%d in %s
  %s
r   )r   r)   r   errorErrorrM   r   r   rQ   lstripKeyboardInterruptrI   )r   fnr   lines       r   __str__zTracebackEntry.__str__   s    	TYBBx~ 	 	 	BBB	z#	t~&&--//DD  	 	 		DDD+r4;q=$.MMMs    00&A, ,A<c                 .    | j         j        j        j        S r    )rM   r   r   r   r6   s    r   r   zTracebackEntry.name   s    z"**r$   zco_name of underlaying coder    )r?   r@   rA   rB   rr   r   r   rt   rC   rM   rx   rz   rQ   r)   r~   localsr   r   r   r.   r   r   r   r&   r$   r   ri   ri      sh       ))KH- - -      6 6 X6 9 9 X9P P P 0 0 X0
 $ $ X$# # #Xit-JKKF	 	 	3 3 3! ! ! !0 Xi  F  N N N+ + +8D$&CDDDDDr$   ri   c                   L     e Zd ZdZeZd Zd
dZ fdZd fdZ	d Z
d	 Z xZS )	Tracebackz_ Traceback objects encapsulate and offer higher level
        access to Traceback entries.
    c                      t          |d          r+ fd}t                                ||                     dS t                               |           dS )z0 initialize from given python traceback object. tb_nextc              3   T   K   | "                     |           V  | j        } |  d S d S r    )Entryr   )curr   s    r   fzTraceback.__init__.<locals>.f  s8      o**S//)))+C ooooor$   N)r   listr   )r   tbr   s   `  r   r   zTraceback.__init__  sl    2y!! 	$& & & & & MM$"&&&&&MM$#####r$   Nc                    | D ]~}|j         j        }|j        }|||k    ra|%t          |d          r|                    |          s:||j        |k    r-||j         j        j        |k    rt          |j                  c S | S )a   return a Traceback instance wrapping part of this Traceback

            by provding any combination of path, lineno and firstlineno, the
            first frame to start the to-be-returned traceback is determined

            this allows cutting the first part of a Traceback instance e.g.
            for formatting reasons (removing some uninteresting bits that deal
            with handling of the exception/traceback)
        Nrelto)	rM   r   r)   r   r   rI   r   r   rk   )r   r)   rI   r   excludepathr   r   codepaths           r   cutzTraceback.cut  s      	. 	.A7<DyHT!1!1$GHg,F,F$^^K00 %18v#5#5$(@K(O(O -----r$   c                     t          t          |                               |          }t          |t	          t          d                              r|                     |          }|S r   )superr   __getitem__r   typeslice	__class__)r   r   valr   s      r   r   zTraceback.__getitem__!  sT    It$$0055c4a>>** 	&..%%C
r$   c                 ,    |                                   S r    )r   )r   s    r   <lambda>zTraceback.<lambda>'  s    ajjll"2 r$   c                 <    t          t          ||                     S )as   return a Traceback instance with certain items removed

            fn is a function that gets a single argument, a TracebackItem
            instance, and should return True when the item should be added
            to the Traceback, False when not

            by default this removes all the TracebackItems which are hidden
            (see ishidden() above)
        )r   filter)r   r   s     r   r   zTraceback.filter'  s     D))***r$   c                     t          dt          |            dz
  d          D ]"}| |         }|                                s|c S #| d         S )zc return last non-hidden traceback entry that lead
        to the exception of a traceback.
        r   )rangelenr   )r   ientrys      r   getcrashentryzTraceback.getcrashentry3  s]     rCII:a<,, 	 	AGE>>## Bxr$   c           	         i }t          |           D ]\  }}|j        j        j        t	          |j        j        j                  |j        f}|                    |g           }|rI|j        }|j        }|D ]8}|	                    |
                    t          ||                    r|c c S 9|                    |j        j                   dS )z return the index of the frame/TracebackItem where recursion
            originates if appropriate, None if no recursion occurred
        )__recursioncache_locals_1__recursioncache_locals_2N)	enumeraterM   r   r)   idr   rI   
setdefaultrK   rb   rU   co_equalrd   )	r   cacher   r   r   lr   locotherlocs	            r   recursionindexzTraceback.recursionindex=  s     !$ 	+ 	+HAu
 +"'EK,<,@)A)A5<OC  b))A !Kj ! ! !Hyy252: "( "< "< = = !  !! HHU[)****tr$   )NNNN)r?   r@   rA   rB   ri   r   r   r   r   r   r   r   __classcell__)r   s   @r   r   r      s          E	$ 	$ 	$   *     32 
+ 
+ 
+ 
+        r$   r   z6__recursioncache_locals_1 == __recursioncache_locals_2?rU   c                   P    e Zd ZdZdZddZd ZddZd Zd	 Z		 	 ddZ
d Zd ZdS )ExceptionInfozX wraps sys.exc_info() objects and offers
        help for navigating the traceback.
    rO   Nc                    ||t          j                    }|gt          |d         t                    rLt	          |d         dd           }|t          |d                   }|r|                    d          rd| _        || _        |d         | _	        |d         | _
        |d         | _        | j	        j        | _        t          j                            | j                  | _        d S )Nr   msgzassert zAssertionError: r      )sysexc_infor   AssertionErrorgetattrr   
startswith
_striptext_excinfor   valuer   r?   typenamer   r   r   	traceback)r   tupr   s      r   r   zExceptionInfo.__init__]  s    ;,..CJs1v~$F$F"3q65$77#"3q6{{H 9 3 3I > > 9&8DOF	V
a&	***4733r$   c                 >    d| j         t          | j                  fz  S )Nz<ExceptionInfo %s tblen=%d>)r   r   r   r6   s    r   rz   zExceptionInfo.__repr__r  s%    ,M3t~..00 0 	0r$   Fc                     t          | j        | j                  }d                    |          }|                                }|r6|                    | j                  r|t          | j                  d         }|S )a.   return the exception as a string

            when 'tryshort' resolves to True, and the exception is a
            py.code._AssertionError, only the actual exception part of
            the exception representation is returned (so 'AssertionError: ' is
            removed from the beginning)
        rO   N)r	   r   r   joinrstripr   r   r   )r   tryshortlinestexts       r   exconlyzExceptionInfo.exconlyv  sp     &di<<wwu~~{{}} 	3t// 3C00112r$   c                 ,    t          | j        |          S )z4 return True if the exception is an instance of exc )r   r   )r   excs     r   errisinstancezExceptionInfo.errisinstance  s    $*c***r$   c                     |                      d          }| j                                        }|j        j        j        j        |j        }}t          ||dz   |          S )NTr   r   )	r   r   r   rM   r   r   r   rI   ReprFileLocation)r   r   r   r)   rI   s        r   _getreprcrashzExceptionInfo._getreprcrash  sT    ,,,--,,..{'+7ffQh888r$   rq   Tc           
         |dk    r]t          t          t          j        | j        | j        | j        d         j                            |                                           S t          |||||          }|	                    |           S )aA   return str()able representation of this exception info.
            showlocals: show locals per traceback entry
            style: long|short|no|native traceback style
            tbfilter: hide entries (where __tracebackhide__ is true)

            in case of style==native, tbfilter and showlocals is ignored.
        nativer   )
showlocalsstyleabspathtbfilterfuncargs)
ReprExceptionInfoReprTracebackNativer   format_exceptionr   r   rk   r   FormattedExcinforepr_excinfo)r   r   r   r   r   r   fmts          r   getreprzExceptionInfo.getrepr  s     H$%8*IJN1%/ & &
 &&((* * * !hC C C %%%r$   c                     | j         d         }t          |j        |j        dz   |                                           }t          |          S Nr   r   )r   r   r)   rI   r   r   r   r   r   s      r   r   zExceptionInfo.__str__  s;    r"uz5<!+;T\\^^LL3xxr$   c                     | j         d         }t          |j        |j        dz   |                                           }|                                S r  )r   r   r)   rI   r   __unicode__r  s      r   r  zExceptionInfo.__unicode__  s@    r"uz5<!+;T\\^^LL   r$   )NNr>   )Frq   FTF)r?   r@   rA   rB   r   r   rz   r   r   r   r   r   r  r&   r$   r   r   r   X  s          J4 4 4 4*0 0 0    + + +9 9 9 /57<& & & &,  
! ! ! ! !r$   r   c                   n    e Zd ZdZdZdZ	 	 ddZd Zd	 Zd
 Z	d Z
ddZddZd ZddZd Zd Zd ZdS )r   z@ presenting information about failing Functions and Generators. >EFrq   Tc                 Z    || _         || _        || _        || _        || _        i | _        d S r    )r   r   r   r   r   r   )r   r   r   r   r   r   s         r   r   zFormattedExcinfo.__init__  s0    $
  r$   c                 H   	 t          |                    t          |          dz
                      }n;# t          $ r   	 t          |d                   }n# t          $ r   Y Y dS xY wY nxY wdt          |          t          |                                          z
  z   S )Nr   r   r      )r   rP   r   r   r   )r   r.   ss      r   
_getindentzFormattedExcinfo._getindent  s    
	F''FA6677AA  	 	 		r
OO$   qqq	 
 CFFS__,--s'   25 A-AA-A($A-(A-c                 f    |                     | j                  }||                                }|S r    )r   r   deindent)r   r   r.   s      r   _getentrysourcez FormattedExcinfo._getentrysource  s/    //__&&Fr$   c                 @    t           j                            |          S r    r\   )r   objs     r   	_safereprzFormattedExcinfo._saferepr  s    u~~c"""r$   c                     | j         r\g }|j                            d          D ]/\  }}|                    ||                     |          f           0t          |          S d S )NT)r;   )r   rM   r=   rd   r  ReprFuncArgs)r   r   argsargnameargvalues        r   	repr_argszFormattedExcinfo.repr_args  sx    = 	&D%*[%8%8T%8%B%B A A!WdnnX&>&>?@@@@%%%		& 	&r$   r   Nc                    g }||t          |j                  k    r!t          j                            d          }d}|dk     r|t          |          z  }d}|r6|                    ||j        |                                         z              n|j        d|         D ]}|                    ||z              |                    | j        dz   |j        |         z              |j        |dz   d         D ]}|                    ||z              |D|rdn|                     |          }|	                    | 
                    ||d	                     |S )
z. return formatted and marked up source lines. Nr   r   z    z   r   r  T)indentmarkall)r   r   r   r   r5   rd   r   flow_markerr  extendget_exconly)	r   r.   
line_indexexcinforp   r   space_prefixr   r  s	            r   
get_sourcezFormattedExcinfo.get_source  si   >Z3v|+<+<<<W^^E**FJ>>#f++%J 	2LLZ(@(F(F(H(HHIIII[j[1 2 2\D01111LL)E1FL4LLMMMZ\]]3 2 2\D01111<QQT__V%<%<FLL))'&$)OOPPPr$   r  c                     g }d|z  }|                     d                              d          }| j        |dd          z   }|D ]}|                    ||z              |s|}|S )N Tr   
r   )r   splitfail_markerrd   )r   r!  r  r  r   exlines
failindentr   s           r   r  zFormattedExcinfo.get_exconly  s    v//4/0066t<<%qrr
2
 	$ 	$DLLd*+++ $#
r$   c                 (   | j         rg }d |D             }|                                 |D ]V}||         }|dk    r|                    d           &|                     |          }|                    |dd|           Wt	          |          S d S )Nc                 *    g | ]}|d          dk    |S )r   @r&   ).0r   s     r   
<listcomp>z0FormattedExcinfo.repr_locals.<locals>.<listcomp>  s!    ;;;CSVs]]C]]]r$   __builtins__z__builtins__ = <builtins>10 = )r   sortrd   r  
ReprLocals)r   r   r   keysr   r   str_reprs          r   repr_localszFormattedExcinfo.repr_locals  s    ? 	%E;;6;;;DIIKKK A At>))LL!<====
  $~~e44H LLhh!?@@@@
 e$$$)	% 	%r$   c                    |                      |          }|"t          j                            d          }d}n*|j        t          |                                d          z
  }g }|j        }|| j        }|dv r|dk    }|s| 	                    |          nd }| 
                    ||||          }	|                    |	           |rd|j        z  }
n|r|j        pd}
|                     |j                  }t!          ||j        dz   |
          }d }|s|                     |j                  }t'          |||||          S |r*|                    |                     |d	
                     t'          |d d d |          S )Nr   r   ro   rp   )rp   zin %srO   r   r  )r  )r  r   r   r5   rI   r   r   rr   r   r  r#  r  r   r   	_makepathr)   r   r7  r   	ReprEntryr  )r   r   r!  r.   r   r   r   rp   reprargsr  messager)   filelocrepr
localsreprs                 r   repr_traceback_entryz%FormattedExcinfo.repr_traceback_entry  s   %%e,,>W^^E**FJJ E,D,D,F,F(J(JJJ!=JE%%%W$E49Ct~~e,,,tH
G5IIALLOOO =!EJ/!6g&6<">>%*--D*4aIIKJ ="..u|<<
UHj+uMMM 	>LL))'!)<<===dD%888r$   c                     | j         st	 t          j                                                            |          }n# t
          $ r |cY S w xY wt          |          t          t          |                    k     r|}|S r    )r   r   r)   r*   bestrelpathOSErrorr   r   )r   r)   nps      r   r9  zFormattedExcinfo._makepath8  s{    | 	W]]__0066   2wwSYY''s   1; A
	A
c                    |j         }| j        r |j                    }d }|                    t                    r%dt          |j                  v r |j                    }|d         }g }d }t          |          D ]D\  }}||k    r|pd }	| 	                    ||	          }
|
                    |
           ||k    rd} nEt          ||| j                  S )Nz maximum recursion depth exceededr   z/!!! Recursion detected (same locals & position))r   )r   r   r   r   RuntimeErrorr   r   r   r   r?  rd   ReprTracebackr   )r   r!  r   r   lastentries	extralineindexr   einfo	reprentrys              r   repr_tracebackzFormattedExcinfo.repr_tracebackB  s    %	= 	+(	(**I  .. 	<1S5G5GGG!9!9!;!;}	%i00 	 	LE5U]/74E11%??INN9%%%&&M	 ' WitzBBBBr$   c                 t    |                      |          }|                                }t          ||          S r    )rM  r   r   )r   r!  reprtraceback	reprcrashs       r   r   zFormattedExcinfo.repr_excinfoV  s6    ++G44))++	 	:::r$   )Frq   TTF)r   NF)r  Fr    )r?   r@   rA   rB   r  r(  r   r  r  r  r  r#  r  r7  r?  r9  rM  r   r&   r$   r   r   r     s        JJKK/57<   . . .  # # #& & &   ,
 
 
 
% % %.9 9 9 9@  C C C(; ; ; ; ;r$   r   c                        e Zd Zd Zd Zd ZdS )TerminalReprc                     |                                  }t          j        d         dk     r|                    d          }|S )Nr   r   zutf-8)r  r   version_infoencode)r   r  s     r   r   zTerminalRepr.__str__\  s<    A""!!Ar$   c                     t           j                                        }t           j                            |          }|                     |           |                                                                S )N)file)r   r]   TextIOTerminalWriter
toterminalgetvaluer   )r   r]   tws      r   r  zTerminalRepr.__unicode__b  sW     U\\^^U!!r!**{{}}""$$$r$   c                 4    d| j         t          |           fz  S )Nz<%s instance at %0x>)r   r   r6   s    r   rz   zTerminalRepr.__repr__j  s    %4'AAAr$   N)r?   r@   rA   r   r  rz   r&   r$   r   rR  rR  [  sF          % % %B B B B Br$   rR  c                   "    e Zd Zd ZddZd ZdS )r   c                 0    || _         || _        g | _        d S r    )rO  rP  sections)r   rO  rP  s      r   r   zReprExceptionInfo.__init__o  s    *"r$   -c                 @    | j                             |||f           d S r    )r`  rd   )r   r   contentseps       r   
addsectionzReprExceptionInfo.addsectiont  s%    dGS122222r$   c                     | j                             |           | j        D ]1\  }}}|                    ||           |                    |           2d S r    )rO  rZ  r`  rd  r   )r   r\  r   rc  rd  s        r   rZ  zReprExceptionInfo.toterminalw  sd    %%b)))"&- 	 	D'3FF3GGG	 	r$   N)ra  )r?   r@   rA   r   re  rZ  r&   r$   r   r   r   n  sF          
3 3 3 3    r$   r   c                       e Zd ZdZd Zd ZdS )rF  _ c                 0    || _         || _        || _        d S r    )reprentriesrI  r   )r   rj  rI  r   s       r   r   zReprTraceback.__init__  s    &"


r$   c                    d }t          | j                  D ]\  }}|j        dk    r|                    d           |                    |           |t          | j                  dz
  k     rK| j        |dz            }|j        dk    s|j        dk    r%|j        dk    r|                    | j                   | j        r|                    | j                   d S d S )Nrq   rO   r   rp   )	r   rj  r   r   rZ  r   rd  entryseprI  )r   r\  
last_styler   r   
next_entrys         r   rZ  zReprTraceback.toterminal  s    
!$"233 	* 	*HAu{f$$R   3t'((1,,,!-ac2
;&((;'))j.>&.H.HFF4=)))> 	$GGDN#####	$ 	$r$   N)r?   r@   rA   rl  r   rZ  r&   r$   r   rF  rF  }  s7        H  
$ $ $ $ $r$   rF  c                       e Zd Zd ZdS )r   c                 L    d| _         t          |          g| _        d | _        d S )Nr   )r   ReprEntryNativerj  rI  r   tbliness     r   r   zReprTracebackNative.__init__  s'    
+G445r$   N)r?   r@   rA   r   r&   r$   r   r   r     s#            r$   r   c                       e Zd ZdZd Zd ZdS )rq  r   c                     || _         d S r    r   rr  s     r   r   zReprEntryNative.__init__  s    


r$   c                 `    |                     d                    | j                             d S )NrO   )writer   r   )r   r\  s     r   rZ  zReprEntryNative.toterminal  s(    
$$%%%%%r$   N)r?   r@   rA   r   r   rZ  r&   r$   r   rq  rq    s7        E  & & & & &r$   rq  c                   $    e Zd ZdZd Zd Zd ZdS )r:  rh  c                 L    || _         || _        || _        || _        || _        d S r    )r   reprfuncargs
reprlocalsreprfilelocr   )r   r   r{  r|  r=  r   s         r   r   zReprEntry.__init__  s+    
($&


r$   c                 \   | j         dk    rS| j                            |           | j        D ]/}|                    d          }|                    |d|           0d S | j        r| j                            |           | j        D ]/}|                    d          }|                    |d|           0| j        r/|                    d           | j                            |           | j        r8| j        r|                    d           | j                            |           d S d S )Nrp   zE   T)boldredrO   )r   r}  rZ  r   r   r   r{  r|  )r   r\  r   r  s       r   rZ  zReprEntry.toterminal  sA   :  ''+++
 2 2oof--4S1111F 	-((,,,J 	. 	.D//&))CGGDtG----? 	+GGBKKKO&&r*** 	,z ''+++++	, 	,r$   c                 Z    d                     | j                  d| j        d| j        S )Nr&  )r   r   r|  r}  r6   s    r   r   zReprEntry.__str__  s5    #yy4444##//1 	1r$   N)r?   r@   rA   	localssepr   rZ  r   r&   r$   r   r:  r:    sF        I  , , ,,1 1 1 1 1r$   r:  c                       e Zd Zd Zd ZdS )r   c                 J    t          |          | _        || _        || _        d S r    )r   r)   rI   r<  )r   r)   rI   r<  s       r   r   zReprFileLocation.__init__  s!    II	r$   c                     | j         }|                    d          }|dk    r
|d |         }|                    | j        d| j        d|           d S )Nr&  r   :z: )r<  findr   r)   rI   )r   r\  r   r   s       r   rZ  zReprFileLocation.toterminal  s]     lHHTNN77bqb'C
diiicc:;;;;;r$   Nr?   r@   rA   r   rZ  r&   r$   r   r   r     s2          
< < < < <r$   r   c                       e Zd Zd Zd ZdS )r4  c                     || _         d S r    rv  )r   r   s     r   r   zReprLocals.__init__  s    


r$   c                 D    | j         D ]}|                    |           d S r    )r   r   )r   r\  r   s      r   rZ  zReprLocals.toterminal  s.    J 	 	DGGDMMMM	 	r$   Nr  r&   r$   r   r4  r4    s2              r$   r4  c                       e Zd Zd Zd ZdS )r  c                     || _         d S r    )r  )r   r  s     r   r   zReprFuncArgs.__init__  s    			r$   c                 @   | j         rd}| j         D ]^\  }}|d|}t          |          t          |          z   dz   |j        k    r|r|                    |           |}Q|r	|d|z   z  }\|}_|r|                    |           |                    d           d S d S )NrO   r2  r   z, )r  r   	fullwidthr   )r   r\  	linesofarr   r   nss         r   rZ  zReprFuncArgs.toterminal  s    9 	I#y 
' 
'e!%uu-r77S^^+a/",>>  +	***!#II  '!TBY.		$&		 #	"""GGBKKKKK	 	r$   Nr  r&   r$   r   r  r    s2              r$   r  Tc                    | reddl m}  t                              dg           }|                    t
          j        j        j                   | j        t
          j        j        _        |rkt                              dg           }|                    t
          j        j        j	                   t
          j
        j	        t
          j        j        _	        dS dS )z? put compile and AssertionError builtins to Python's builtins. r   )	assertionr   compileN)r/   r  oldbuiltinsr   rd   r   rY   builtinsr   r  r   )r  r  r   s      r   patch_builtinsr    s     F&&&&&&""#3R88	$3444-6-E
* 6""9b11	$,---&(go
###6 6r$   c                     | r3t           d                                         t          j        j        _        |r5t           d                                         t          j        j        _        dS dS )zB remove compile and AssertionError builtins from Python builtins. r   r  N)r  popr   rY   r  r   r  )r  r  s     r   unpatch_builtinsr    sc     Q-89I-J-N-N-P-P
* C&1)&<&@&@&B&B
###C Cr$   c                 t   	 | j         S # t          $ r t          | d|           } t          | d|           } t          | d|           } t          | d|           } |rYt          | d          sIt          | d          r9t	          |           s*t          | j        d          }t          |d          r|cY S | cY S w xY w)	z( return code object for given function. im_func	func_coderL   __code__r   __call__F)trycall)r  r   r   r   r   r   r  )r  r  r   s      r   r   r     s    | 
 
 
c9c**c;,,c8S))c:s++ 	73(899 	sJ''  s|U;;;1.// HHH



s   	 B'B72B76B7)TT)T)&r   r   inspectr   r   r   r   builtin_reprrY   
_tryimportr   rT  r   r	   py._code._py2tracebackr`   r   rE   ri   r   r   r  r   r   r   rR  r   rF  r   rq  r:  r   r4  r  r  r  r  r   r&   r$   r   <module>r     s   				 



 7 7 7 7 7 7 7 7 7 7
*

	
2
2A!///////<<<<<<    9* 9* 9* 9* 9*6 9* 9* 9*v: : : : :F : : :zoE oE oE oE oEV oE oE oEdX X X X X X X Xt 7K   V! V! V! V! V!F V! V! V!rh; h; h; h; h;v h; h; h;TB B B B B B B B&       $ $ $ $ $L $ $ $0    -   & & & & &l & & &#1 #1 #1 #1 #1 #1 #1 #1J< < < < <| < < <           <   0 
6 
6 
6 
6C C C C     r$   