grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026 ”qcŸVã@sðdZddlZddlZddlZddlZddddddd d d d d ddddddddgZddd„Zdd„Zdddd„Zddd „Z ddd„Z dZ dZ 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 r9s zG 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 r Ss   +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)Ú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)r rÚ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Ú ValueErrorr r2Ú 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  c CsFx?|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 d d „Zd d„Zdd„Zdd„Zdd„Z e dd„ƒZ d 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 ú sz(FrameSummary.__init__..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)Nz7r@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 | ƒt j | |j ƒ|rñ|j} nd} |jt| || ddd| ƒƒq˜Wx|D]} t j| ƒ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 „Zed d „ƒZd d„Zdd„Zdd„Z dd„Z dddd„Z dS)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ƒ}d d „|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ú?z File "{}", line {} z {} Ú écss'|]}|jƒr|pdVqdS)ú N)Úisspace)rGÚcrrr rJ&sz;TracebackException.format_exception_only..z {}^ rzz{}: {} )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©r rrr-r+r r r r rrrrrrr*rrrrrr ÚsD                  ? ]