AlkantarClanX12

Your IP : 18.225.195.153


Current Path : /opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/__pycache__/traceback.cpython-35.pyc



��Yf�V�@s�dZddlZddlZddlZddlZddddddd	d
ddd
ddddddddgZddd�Zdd�Zdddd�Zddd	�Z	ddd�Z
dZdZddddd�Z
ddd d�Zd!d�Zd"d#�Zd$d%�Zdddd&d
�Zddd'd�Zdddd(d
�Zdddd)d�Zddd*d�Zddd+d�Zd,d�ZGd-d�d�Zd.d�Zd/d�ZGd0d�de�ZGd1d�d�ZdS)2z@Extract, format and print information about Python stack traces.�N�
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_tbcCsO|dkrtj}x3tj|�j�D]}t|d|dd�q+WdS)zyPrint 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�item�r�./opt/alt/python35/lib64/python3.5/traceback.py�
print_lists	r!cCstj|�j�S)a�Format a list of traceback entry tuples for printing.

    Given a list of tuples 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.
    )rrr)rrrr rs
cCs tt|d|�d|�dS)aPrint 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.
    �limitrN)r!r)�tbr"rrrr r+scCst|d|�j�S)z5A shorthand for 'format_list(extract_tb(tb, limit))'.r")rr)r#r"rrr r5scCstjt|�d|�S)a�Return list of up to limit 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 quadruple (filename, line
    number, function name, text) representing the information that is
    usually printed for a stack trace.  The text is a string with
    leading and trailing whitespace stripped; if the source is not
    available it is None.
    r")r�extractr)r#r"rrr r9szG
The above exception was the direct cause of the following exception:

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

TcCsd|dkrtj}xHtt|�||d|�jd|�D]}t|d|dd�q@WdS)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.
    Nr"�chainrrr)rrr�typerr)�etype�valuer#r"rr%�linerrr rSs
	+cCs.ttt|�||d|�jd|��S)azFormat 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().
    r"r%)�listrr&r)r'r(r#r"r%rrr rhscCstt||d�j��S)aFormat the exception part of a traceback.

    The arguments are the exception type and value such as given by
    sys.last_type and sys.last_value. The return value is a list of
    strings, each ending in a newline.

    Normally, the list contains a single string; however, for
    SyntaxError exceptions, it contains several lines that (when
    printed) display detailed information about where the syntax
    error occurred.

    The message indicating which exception occurred is always the last
    string in the list.

    N)r*rr)r'r(rrr rxscCs@t|�}|dks|r,d|}nd||f}|S)Nz%s
z%s: %s
)�	_some_str)r'r(�valuestrr)rrr �_format_final_exc_line�s

r-c	Cs.yt|�SWndt|�jSYnXdS)Nz<unprintable %s object>)�strr&�__name__)r(rrr r+�sr+cCs&ttj�d|d|d|�dS)z>Shorthand for 'print_exception(*sys.exc_info(), limit, file)'.r"rr%N)rr�exc_info)r"rr%rrr r	�scCs%djttj�d|d|��S)z%Like print_exc() but return a string.rr"r%)�joinrrr0)r"r%rrr r
�scCsAttd�std��ttjtjtj|||�dS)znThis is a shorthand for 'print_exception(sys.last_type,
    sys.last_value, sys.last_traceback, limit, file)'.�	last_typezno last exceptionN)�hasattrr�
ValueErrorrr2�
last_value�last_traceback)r"rr%rrr r�scCs;|dkrtj�j}tt|d|�d|�dS)z�Print 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"rrrr r
�scCs1|dkrtj�j}tt|d|��S)z5Shorthand for 'format_list(extract_stack(f, limit))'.Nr")rr7r8rr)r9r"rrr r�scCsD|dkrtj�j}tjt|�d|�}|j�|S)asExtract 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.
    Nr")rr7r8rr$r�reverse)r9r"�stackrrr r�s
	
cCsFx?|dk	rAy|jj�Wntk
r4YnX|j}qWdS)zEClear all references to local variables in the frames of a traceback.N)�tb_frame�clear�RuntimeError�tb_next)r#rrr r�s
c@s|eZdZdZdZdddd	d
d	dd�Zd
d�Zdd�Zdd�Zdd�Z	e
dd��Zd	S)ra,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�name�_line�locals�lookup_lineTNr)cCsc||_||_||_||_|r1|j|rVtdd�|j�D��nd|_dS)a�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.
        css'|]\}}|t|�fVqdS)N)�repr)�.0�k�vrrr �	<genexpr>sz(FrameSummary.__init__.<locals>.<genexpr>N)r@rArBrCr)�dict�itemsrD)�selfr@rArBrErDr)rrr �__init__�s				zFrameSummary.__init__cCs�t|t�rU|j|jkoT|j|jkoT|j|jkoT|j|jkSt|t�r�|j|j|j|jf|kStS)N)	�
isinstancerr@rArBrD�tupler)�NotImplemented)rM�otherrrr �__eq__s"zFrameSummary.__eq__cCs |j|j|j|jf|S)N)r@rArBr))rM�posrrr �__getitem__
szFrameSummary.__getitem__cCs"t|j|j|j|jg�S)N)�iterr@rArBr))rMrrr �__iter__szFrameSummary.__iter__cCs%djd|jd|jd|j�S)Nz7<FrameSummary file {filename}, line {lineno} in {name}>r@rArB)rr@rArB)rMrrr �__repr__s	zFrameSummary.__repr__cCs7|jdkr0tj|j|j�j�|_|jS)N)rC�	linecache�getliner@rA�strip)rMrrr r)s!zFrameSummary.line)r@rArBrCrD)r/�
__module__�__qualname__�__doc__�	__slots__rNrSrUrWrX�propertyr)rrrr r�s	
ccsL|dkrtj�jj}x'|dk	rG||jfV|j}q!WdS)z�Walk 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)rr7r8�f_lineno)r9rrr rs
ccs1x*|dk	r,|j|jfV|j}qWdS)z�Walk 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#rrr r+sc	@sXeZdZdZedddddddd	��Zed
d��Zdd
�ZdS)rzA stack of frames.r"N�lookup_linesT�capture_localsFc

Cs`|dkr<ttdd�}|dk	r<|dkr<d}|dk	r|dkritj||�}ntj|d|�}|�}t�}x�|D]�\}}|j}	|	j}
|	j	}|j
|
�tj|
|j
�|r�|j}nd}|jt|
||ddd|��q�Wx|D]}
tj|
�q'W|r\x|D]
}|jqKW|S)a?Create a StackSummary from a traceback or stack object.

        :param frame_gen: A generator that yields (frame, lineno) tuples to
            include 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.
        N�tracebacklimitr�maxlenrEFrD)�getattrr�	itertools�islice�collections�deque�set�f_code�co_filename�co_name�addrY�	lazycache�	f_globals�f_locals�appendr�
checkcacher))
�klass�	frame_genr"rcrd�result�fnamesr9rA�cor@rBrsrrr r$9s6					
	 

zStackSummary.extractcCsnt�}x^|D]V}t|t�r5|j|�q|\}}}}|jt|||d|��qW|S)z�Create a StackSummary from a simple list of tuples.

        This method supports the older Python API. Each tuple should be a
        4-tuple with (filename, lineno, name, line) elements.
        r))rrOrrt)rv�a_listrx�framer@rArBr)rrr ris	
#zStackSummary.from_listcCs�g}x�|D]�}g}|jdj|j|j|j��|jrf|jdj|jj���|jr�xBt|jj	��D]+\}}|jdjd|d|��q�W|jdj
|��q
W|S)aGFormat 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.
        z  File "{}", line {}, in {}
z    {}
z    {name} = {value}
rBr(r)rtrr@rArBr)r[rD�sortedrLr1)rMrxr|�rowrBr(rrr r}s
		"#zStackSummary.format)r/r\r]r^�classmethodr$rrrrrr r6s.c
@s�eZdZdZddddddddd	d
�Zedd��Zd
d�Zdd�Zdd�Z	dd�Z
dddd�ZdS)ra�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.

    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:`__suppress_context__` The *__suppress_context__* value from the
      original exception.
    - :attr:`stack` A `StackSummary` representing the traceback.
    - :attr:`exc_type` The class of the original traceback.
    - :attr:`filename` For syntax errors - the filename where the error
      occurred.
    - :attr:`lineno` For syntax errors - the linenumber where the error
      occurred.
    - :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:`msg` For syntax errors - the compiler error message.
    r"NrcTrdF�_seenc
Cs�|dkrt�}|j|�|r�|jdk	r�|j|kr�tt|j�|j|jjd|ddd|d|�}nd}|r�|jdk	r�|j|kr�tt|j�|j|jjd|ddd|d|�}	nd}	||_||_|	|_|r|jnd|_t	j
t|�d|d|d|�|_||_
t|�|_|r�t|t�r�|j|_t|j�|_|j|_|j|_|j|_|r�|j�dS)Nr"rcFrdr�)rlrp�	__cause__rr&�
__traceback__�__context__�
exc_traceback�__suppress_context__rr$rr;�exc_typer+�_str�
issubclass�SyntaxErrorr@r.rA�text�offset�msg�_load_lines)
rMr��	exc_valuer�r"rcrdr��cause�contextrrr rN�sT	
				zTracebackException.__init__cOstt|�||j||�S)z.Create a TracebackException from an exception.)rr&r�)rM�exc�args�kwargsrrr �from_exception�sz!TracebackException.from_exceptioncCsKx|jD]
}|jq
W|jr1|jj�|jrG|jj�dS)z7Private API. force all lines in the stack to be loaded.N)r;r)r�r�r�)rMr|rrr r��s	
	zTracebackException._load_linescCs|j|jkS)N)�__dict__)rMrRrrr rS�szTracebackException.__eq__cCs|jS)N)r�)rMrrr �__str__�szTracebackException.__str__c	cs||jdkr$td|j�VdS|jj}|jj}|dkrV|d|}t|jt�s}t||j�VdS|jp�d}t|j	�p�d}dj
||�V|j}|j}|dk	rXdj
|j
��V|dk	rX|jd	�}tt|�|�d
}|d|�j�}dd�|D�}d
j
dj|��V|jpdd}dj
||�VdS)a�Format the exception part of the traceback.

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

        Normally, the generator emits a single string; however, for
        SyntaxError exceptions, it emites several lines that (when
        printed) display detailed information about where the syntax
        error occurred.

        The message indicating which exception occurred is always the last
        string in the output.
        N�__main__�builtins�.z<string>�?z  File "{}", line {}
z    {}
�
�css'|]}|j�r|pdVqdS)� N)�isspace)rG�crrr rJ&sz;TracebackException.format_exception_only.<locals>.<genexpr>z    {}^
rz<no detail available>z{}: {}
)r�r�)r�r-r�r]r\r�r�r@r.rArr�r�r[�rstrip�min�len�lstripr1r�)	rM�stype�smodr@rA�badliner��
caretspacer�rrr r�s2
		z(TracebackException.format_exception_onlyr%ccs�|rk|jdk	r5|jjd|�EdHtVn6|jdk	rk|jrk|jjd|�EdHtV|jdk	rdV|jj�EdH|j�EdHdS)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.
        Nr%z#Traceback (most recent call last):
)	r�r�_cause_messager�r��_context_messager�r;r)rMr%rrr r+s
zTracebackException.format)r/r\r]r^rNrr�r�rSr�rrrrrr r�s	9	-)r^rjrhrYr�__all__r!rrrrr�r�rrrr-r+r	r
rr
rrrrrrr*rrrrrr �<module>sD			
?
]