Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib/python3.7/site-packages/py/_code/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/py/_code/__pycache__/code.cpython-37.pyc

B

���]Dn�@szddlZddlZddlmZmZeZej�dd�Z	ej
ddkrNddlmZnddl
mZGdd�de�ZGd	d
�d
e�ZGdd�de�ZGd
d�de�Zeddd�ZGdd�de�ZGdd�de�ZGdd�d�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGd d!�d!e�ZGd"d#�d#e�ZGd$d%�d%e�ZGd&d'�d'e�Z iZ!d/d)d*�Z"d0d+d,�Z#d1d-d.�Z$dS)2�N)�
CO_VARARGS�CO_VARKEYWORDS�repr�reprlib�)�format_exception_onlyc@sReZdZdZdd�Zdd�Zdd�Zedd	��Zed
d��Z	dd
�Z
ddd�ZdS)�Codez$ wrapper around Python code objects cCsdt|d�stj�|�}y |j|_|jd|_|j|_	Wn"t
k
rXtd|f��YnX||_dS)N�co_filename�znot a code object: %r)
�hasattr�py�code�
getrawcoder	�filename�co_firstlineno�firstlineno�co_name�name�AttributeError�	TypeError�raw)�selfZrawcode�r�>/opt/alt/python37/lib/python3.7/site-packages/py/_code/code.py�__init__s
z
Code.__init__cCs|j|jkS)N)r)r�otherrrr�__eq__szCode.__eq__cCs
||kS)Nr)rrrrr�__ne__szCode.__ne__cCs$tj�|jj�}|��s |jj}|S)zs return a path object pointing to source code (note that it
        might not point to an actually existing file). )r�path�localrr	�check)r�prrrr!sz	Code.pathcCs ddlm}|�|j�\}}|S)zM return a py.code.Source object for the full source file of the code
        r)�source)�py._coder"�
findsourcer)rr"�full�_rrr�
fullsource-szCode.fullsourcecCstj�|j�S)zJ return a py.code.Source object for the code object's source only
        )rr
�Sourcer)rrrrr"5szCode.sourceFcCs:|j}|j}|r,||jt@7}||jt@7}|jd|�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_flagsrr�co_varnames)r�varrZargcountrrr�getargs;szCode.getargsN)F)�__name__�
__module__�__qualname__�__doc__rrr�propertyrr'r"r-rrrrrsrc@sNeZdZdZdd�Zedd��Zdd�Zdd	�Zd
d�Z	dd
�Z
ddd�ZdS)�FramezgWrapper around a Python frame holding f_locals and f_globals
    in which expressions can be evaluated.cCs6|jd|_|j|_|j|_||_tj�|j�|_dS)Nr
)	�f_lineno�lineno�	f_globals�f_localsrrr
r�f_code)r�framerrrrMs
zFrame.__init__cCs(|jjdkrtj�d�S|jj�|j�S)z statement this frame is at N�)r
r'rr(�getstatementr5)rrrr�	statementTszFrame.statementcKs"|j��}|�|�t||j|�S)z� evaluate 'code' in the frame

            'vars' are optional additional local variables

            returns the result of the evaluation
        )r7�copy�update�evalr6)rr
�varsr7rrrr?[s

z
Frame.evalcKs*|j��}|�|�tj�||j|�dS)z^ exec 'code' in the frame

            'vars' are optiona; additional local variables
        N)r7r=r>r�builtin�exec_r6)rr
r@r7rrrrBfs

zFrame.exec_cCstj�|�S)zL return a 'safe' (non-recursive, one-line) string repr for 'object'
        )r�io�saferepr)r�objectrrrrosz
Frame.reprcCs|S)Nr)rrErrr�is_truetsz
Frame.is_trueFc	CsLg}xB|j�|�D]2}y|�||j|f�Wqtk
rBYqXqW|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-�appendr7�KeyError)rr,�retval�argrrrr-ws
z
Frame.getargsN)F)r.r/r0r1rr2r<r?rBrrFr-rrrrr3Is	r3c@s�eZdZdZdZdZdd�Zdd�Zedd��Z	ed	d
��Z
dd�Zed
d��Zedd��Z
dd�Zeeddd�Zdd�Zdd�Zd!dd�Zee�Zdd�Zdd�Zdd�Zeeddd �ZdS)"�TracebackEntryz a single entry in a traceback NcCs||_|jd|_dS)Nr
)�	_rawentry�	tb_linenor5)rZrawentryrrrr�szTracebackEntry.__init__cCs|dkst�||_dS)N)�short�long)�AssertionError�_repr_style)r�moderrr�set_repr_style�szTracebackEntry.set_repr_stylecCstj�|jj�S)N)rr
r3rL�tb_frame)rrrrr9�szTracebackEntry.framecCs|j|jjjS)N)r5r9r
r)rrrr�relline�szTracebackEntry.rellinecCsd|jjj|jdfS)Nz<TracebackEntry %s:%d>r
)r9r
rr5)rrrr�__repr__�szTracebackEntry.__repr__cCs|jjj}|�|j�S)z1 py.code.Source object for the current statement )r9r
r'r;r5)rr"rrrr<�s
zTracebackEntry.statementcCs
|jjjS)z path to the source code )r9r
r)rrrrr�szTracebackEntry.pathcCs|jjS)N)r9r7)rrrr�	getlocals�szTracebackEntry.getlocalszlocals of underlaying framecCsP|jdkrJt|j���}tjj||jdd�}t|t�sDt	d|f��||_|jS)ztReinterpret the failing statement and returns a detailed information
           about what operations are performed.NT)Zshould_failz interpret returned non-string %r)
�exprinfo�strr<�striprr
Z_reinterpretr9�
isinstancer)rr"�xrrr�reinterpret�s

zTracebackEntry.reinterpretcCst|jjjd�S)Nr)�maxr9r
r)rrrr�getfirstlinesource�sz!TracebackEntry.getfirstlinesourcec	Cs�ddlm}|jjj}|dkr"dSd}}|dk	rP|jjj}|dk	rP|�|d�}|��}y||j||d�\}}}Wnt	k
r�|jd}YnX|dk	r�|||<|||�S)z return failing source code. r)�getstatementrange_astN)�astnoder
)
Zpy._code.sourcer`r9r
r'r�getr_r5�SyntaxError)	r�astcacher`r"�keyra�startr&�endrrr�	getsource�s$

zTracebackEntry.getsourcecCsHy|jjdStk
rBy|jjdStk
r<dSXYnXdS)z� return True if the current frame has a var __tracebackhide__
            resolving to True

            mostly for internal use
        Z__tracebackhide__FN)r9r7rHr6)rrrr�ishidden�szTracebackEntry.ishiddencCs�yt|j�}Wntjjk
r*d}YnX|jjj}yt|j��	�}Wn$t
k
r^�Ynd}YnXd||jd||fS)Nz???z  File %r:%d in %s
  %s
r
)rYrr�error�Errorr9r
rr<�lstrip�KeyboardInterruptr5)r�fnr�linerrr�__str__�s


zTracebackEntry.__str__cCs|jjjjS)N)r9r
rr)rrrrr�szTracebackEntry.namezco_name of underlaying code)N)r.r/r0r1rQrXrrSr2r9rUrVr<rrW�localsr]r_rhr"rirprrrrrrK�s(
rKcsVeZdZdZeZdd�Zddd�Z�fdd�Zd	d
�fdd�Z	d
d�Z
dd�Z�ZS)�	Tracebackz_ Traceback objects encapsulate and offer higher level
        access to Traceback entries.
    cs8t|d�r(�fdd�}t��||��nt��|�dS)z0 initialize from given python traceback object. �tb_nextc3s$x|dk	r��|�V|j}qWdS)N)�Entryrs)�cur)rrr�f�s
zTraceback.__init__.<locals>.fN)r�listr)r�tbrvr)rrr�s
zTraceback.__init__NcCs~xx|D]p}|jj}|j}|dks(||kr|dksDt|d�rD|�|�s|dksV|j|kr|dksl|jjj|krt|j�SqW|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)	r9r
rrryr5rrrrL)rrr5rZexcludepathr\r
Zcodepathrrr�cuts


z
Traceback.cutcs0tt|��|�}t|ttd���r,|�|�}|S)Nr)�superrr�__getitem__r[�type�slice�	__class__)rre�val)rrrr|s
zTraceback.__getitem__cCs
|��S)N)ri)r\rrr�<lambda>!�zTraceback.<lambda>cCstt||��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)
        )rr�filter)rrnrrrr�!s
zTraceback.filtercCs<x2tdt|�dd�D]}||}|��s|SqW|dS)zc return last non-hidden traceback entry that lead
        to the exception of a traceback.
        ���r
)�range�lenri)r�i�entryrrr�
getcrashentry-s
zTraceback.getcrashentryc		Cs�i}x�t|�D]v\}}|jjjt|jjj�|jf}|�|g�}|rv|j}|j}x&|D]}|�	|j
t||d��rT|SqTW|�|jj�qWdS)z� return the index of the frame/TracebackItem where recursion
            originates if appropriate, None if no recursion occurred
        )Z__recursioncache_locals_1Z__recursioncache_locals_2N)
�	enumerater9r
r�idrr5�
setdefaultr7rFr?�co_equalrG)	r�cacher�r�re�lrv�locZotherlocrrr�recursionindex7s


zTraceback.recursionindex)NNNN)
r.r/r0r1rKrtrrzr|r�r�r��
__classcell__rr)rrrr�s

rrz6__recursioncache_locals_1 == __recursioncache_locals_2�?r?c@sZeZdZdZdZddd�Zdd�Zdd	d
�Zdd�Zd
d�Z	ddd�Z
dd�Zdd�ZdS)�
ExceptionInfozX wraps sys.exc_info() objects and offers
        help for navigating the traceback.
    r:NcCs�|dkr^t��}|dkr^t|dt�r^t|ddd�}|dkrJt|d�}|r^|�d�r^d|_||_|d|_	|d|_
|d|_|j	j|_
tj�|j�|_dS)Nr
�msgzassert zAssertionError: r�)�sys�exc_infor[rP�getattrrY�
startswith�
_striptextZ_excinfor}�valuerxr.�typenamerr
rr�	traceback)r�tuprXrrrrWs



zExceptionInfo.__init__cCsd|jt|j�fS)Nz<ExceptionInfo %s tblen=%d>)r�r�r�)rrrrrVlszExceptionInfo.__repr__FcCsFt|j|j�}d�|�}|��}|rB|�|j�rB|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)
        r:N)rr}r��join�rstripr�r�r�)r�tryshort�lines�textrrr�exconlyos
zExceptionInfo.exconlycCst|j|�S)z4 return True if the exception is an instance of exc )r[r�)r�excrrr�
errisinstanceszExceptionInfo.errisinstancecCs:|jdd�}|j��}|jjjj|j}}t||d|�S)NT)r�r
)	r�r�r�r9r
rr	r5�ReprFileLocation)rr�r�rr5rrr�
_getreprcrash�s
zExceptionInfo._getreprcrashrOTcCsP|dkr4tttjj�|j|j|jdj��|�	��St
|||||d�}|�|�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�stdr��format_exceptionr}r�rLr��FormattedExcinfo�repr_excinfo)rr�r�r�r�r��fmtrrr�getrepr�s	
zExceptionInfo.getreprcCs*|jd}t|j|jd|���}t|�S)Nr�r
)r�r�rr5r�rY)rr�r�rrrrp�s
zExceptionInfo.__str__cCs*|jd}t|j|jd|���}|��S)Nr�r
)r�r�rr5r��__unicode__)rr�r�rrrr��s
zExceptionInfo.__unicode__)NN)F)FrOFTF)
r.r/r0r1r�rrVr�r�r�r�rpr�rrrrr�Rs


r�c@s�eZdZdZdZdZd"dd�Zd	d
�Zdd�Zd
d�Z	dd�Z
d#dd�Zd$dd�Zdd�Z
d%dd�Zdd�Zdd�Zd d!�ZdS)&r�z@ presenting information about failing Functions and Generators. �>�EFrOTcCs(||_||_||_||_||_i|_dS)N)r�r�r�r�r�rd)rr�r�r�r�r�rrrr�szFormattedExcinfo.__init__cCs�yt|�t|�d��}WnPtk
r0�Yn<yt|d�}Wntk
r\�Yn
dSYnXdt|�t|���S)Nr
r�r�)rYr;r�rmrl)rr"�srrr�
_getindent�s
zFormattedExcinfo._getindentcCs |�|j�}|dk	r|��}|S)N)rhrdZdeindent)rr�r"rrr�_getentrysource�sz FormattedExcinfo._getentrysourcecCstj�|�S)N)rrCrD)r�objrrr�	_saferepr�szFormattedExcinfo._safereprcCsF|jrBg}x.|jjdd�D]\}}|�||�|�f�qWt|�SdS)NT)r,)r�r9r-rGr��ReprFuncArgs)rr��args�argnameZargvaluerrr�	repr_args�s
zFormattedExcinfo.repr_argsr�Nc	Cs�g}|dks|t|j�kr*tj�d�}d}|dkr>|t|�7}d}|r`|�||j|���njx$|jd|�D]}|�||�qpW|�|jd|j|�x(|j|dd�D]}|�||�q�W|dk	r�|r�dn|�|�}|�	|j
||dd	��|S)
z. return formatted and marked up source lines. Nz???rz    z   r
r�T)�indent�markall)r�r�rr
r(rGrZ�flow_markerr��extend�get_exconly)	rr"�
line_index�excinforNr�Zspace_prefixror�rrr�
get_source�s$zFormattedExcinfo.get_sourcer�cCsXg}d|}|jdd��d�}|j|dd�}x"|D]}|�||�|s6|}q6W|S)N� T)r��
r
)r��split�fail_markerrG)rr�r�r�r�ZexlinesZ
failindentrorrrr��s
zFormattedExcinfo.get_exconlycCsr|jrng}dd�|D�}|��xD|D]<}||}|dkrF|�d�q&|�|�}|�d||f�q&Wt|�SdS)NcSsg|]}|ddkr|�qS)r�@r)�.0r�rrr�
<listcomp>�sz0FormattedExcinfo.repr_locals.<locals>.<listcomp>�__builtins__z__builtins__ = <builtins>z
%-10s = %s)r��sortrGr��
ReprLocals)rrqr��keysrr�Zstr_reprrrr�repr_locals�s

zFormattedExcinfo.repr_localscCs|�|�}|dkr$tj�d�}d}n|jt|��d�}g}|j}|dkrP|j}|dkr�|dk}|sn|�	|�nd}|j
||||d�}	|�|	�|r�d|j}
n|r�|j
p�d}
|�|j�}t||jd|
�}d}
|s�|�|j�}
t|||
||�S|�r|�|j|d	d
��t|ddd|�S)Nz???r)rNrOrN)rNzin %sr:r
r�)r�)r�rr
r(r5r^r_rQr�r�r�r�rr��	_makepathrr�r�rq�	ReprEntryr�)rr�r�r"r�r�r�rNZreprargsr��messager�filelocreprZ
localsreprrrr�repr_traceback_entrys4

z%FormattedExcinfo.repr_traceback_entrycCsL|jsHytj���|�}Wntk
r.|SXt|�tt|��krH|}|S)N)r�rrrZbestrelpath�OSErrorr�rY)rr�nprrrr�/szFormattedExcinfo._makepathcCs�|j}|jr|��}d}|�t�r8dt|j�kr8|��}|d}g}d}xHt|�D]<\}}||krf|phd}	|�	||	�}
|�
|
�||krRd}PqRWt|||jd�S)Nz maximum recursion depth exceededr�z/!!! Recursion detected (same locals & position))r�)
r�r�r�r��RuntimeErrorrYr�r�r�r�rG�
ReprTracebackr�)rr�r�r��last�entries�	extraline�indexr�ZeinfoZ	reprentryrrr�repr_traceback9s$

zFormattedExcinfo.repr_tracebackcCs|�|�}|��}t||�S)N)r�r�r�)rr��
reprtraceback�	reprcrashrrrr�Ms
zFormattedExcinfo.repr_excinfo)FrOTTF)r�NF)r�F)N)r.r/r0r1r�r�rr�r�r�r�r�r�r�r�r�r�r�rrrrr��s



 
r�c@s$eZdZdd�Zdd�Zdd�ZdS)�TerminalReprcCs$|��}tjddkr |�d�}|S)Nrrzutf-8)r�r��version_info�encode)rr�rrrrpSs
zTerminalRepr.__str__cCs.tj��}tjj|d�}|�|�|����S)N)�file)rrCZTextIOZTerminalWriter�
toterminal�getvaluerZ)rrC�twrrrr�Ys

zTerminalRepr.__unicode__cCsd|jt|�fS)Nz<%s instance at %0x>)rr�)rrrrrVaszTerminalRepr.__repr__N)r.r/r0rpr�rVrrrrr�Rsr�c@s&eZdZdd�Zd	dd�Zdd�ZdS)
r�cCs||_||_g|_dS)N)r�r��sections)rr�r�rrrrfszReprExceptionInfo.__init__�-cCs|j�|||f�dS)N)r�rG)rr�content�seprrr�
addsectionkszReprExceptionInfo.addsectioncCs<|j�|�x*|jD] \}}}|�||�|�|�qWdS)N)r�r�r�r�ro)rr�rr�r�rrrr�nszReprExceptionInfo.toterminalN)r�)r.r/r0rr�r�rrrrr�es
r�c@s eZdZdZdd�Zdd�ZdS)r�z_ cCs||_||_||_dS)N)�reprentriesr�r�)rr�r�r�rrrrwszReprTraceback.__init__cCs�d}x~t|j�D]p\}}|jdkr,|�d�|�|�|t|j�dkr|j|d}|jdkst|jdkr|jdkr|�|j�qW|jr�|�|j�dS)NrOr:r
rN)	r�r�r�ror�r�r��entrysepr�)rr�Z
last_styler�r�Z
next_entryrrrr�|s



zReprTraceback.toterminalN)r.r/r0r�rr�rrrrr�tsr�c@seZdZdd�ZdS)r�cCsd|_t|�g|_d|_dS)Nr�)r��ReprEntryNativer�r�)r�tblinesrrrr�szReprTracebackNative.__init__N)r.r/r0rrrrrr��sr�c@s eZdZdZdd�Zdd�ZdS)r�r�cCs
||_dS)N)r�)rr�rrrr�szReprEntryNative.__init__cCs|�d�|j��dS)Nr:)�writer�r�)rr�rrrr��szReprEntryNative.toterminalN)r.r/r0r�rr�rrrrr��sr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	r�z_ cCs"||_||_||_||_||_dS)N)r��reprfuncargs�
reprlocals�reprfilelocr�)rr�r�r�r�r�rrrr�s
zReprEntry.__init__cCs�|jdkrD|j�|�x(|jD]}|�d�}|j|d|d�qWdS|jrV|j�|�x(|jD]}|�d�}|j|d|d�q^W|jr�|�d�|j�|�|jr�|jr�|�d�|j�|�dS)NrNzE   T)Zbold�redr:)r�r�r�r�r�ror�r�)rr�ror�rrrr��s$




zReprEntry.toterminalcCsdd�|j�|j|jfS)Nz%s
%s
%sr�)r�r�r�r�)rrrrrp�szReprEntry.__str__N)r.r/r0Z	localsseprr�rprrrrr��sr�c@seZdZdd�Zdd�ZdS)r�cCst|�|_||_||_dS)N)rYrr5r�)rrr5r�rrrr�s
zReprFileLocation.__init__cCs@|j}|�d�}|dkr$|d|�}|�d|j|j|f�dS)Nr�r�z	%s:%s: %s)r��findrorr5)rr�r�r�rrrr��s

zReprFileLocation.toterminalN)r.r/r0rr�rrrrr��sr�c@seZdZdd�Zdd�ZdS)r�cCs
||_dS)N)r�)rr�rrrr�szReprLocals.__init__cCsx|jD]}|�|�qWdS)N)r�ro)rr�rorrrr��szReprLocals.toterminalN)r.r/r0rr�rrrrr��sr�c@seZdZdd�Zdd�ZdS)r�cCs
||_dS)N)r�)rr�rrrr�szReprFuncArgs.__init__cCs�|jr�d}xb|jD]X\}}d||f}t|�t|�d|jkrT|rN|�|�|}q|rf|d|7}q|}qW|r||�|�|�d�dS)Nr:z%s = %sr�z, )r�r�Z	fullwidthro)rr�Z	linesofarrr��nsrrrr��s

zReprFuncArgs.toterminalN)r.r/r0rr�rrrrr��sr�TcCsj|r8ddlm}t�dg�}|�tjjj�|jtjj_|rft�dg�}|�tjjj	�tj
j	tjj_	dS)z? put compile and AssertionError builtins to Python's builtins. r)�	assertionrP�compileN)r#r�oldbuiltinsr�rGrrA�builtinsrPrr
)rrr�rrr�patch_builtins�srcCs0|rtd��tjj_|r,td��tjj_dS)zB remove compile and AssertionError builtins from Python builtins. rPrN)r�poprrArrPr)rrrrr�unpatch_builtins�srcCs�y|jStk
r�t|d|�}t|d|�}t|d|�}t|d|�}|r�t|d�s�t|d�r�tjj�|�s�t|j	dd�}t|d�r�|S|SXd	S)
z( return code object for given function. Zim_func�	func_coder8�__code__r�__call__F)�trycallN)
rrr�rrr��inspect�isclassrr	)r�r
r\rrrrs
r)TT)TT)T)%rr�rrrrZbuiltin_reprrAZ
_tryimportrr�r�rZpy._code._py2tracebackrErr3rKrwrrrr�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrr�<module>s:;<qYW*	%