grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026o ®û|jnfã@sJdZddlZddlZddlZddlZgd¢Zd8dd„Zdd„Zd9dd „Zd8d d „Z d8d d „Z dZ dZ Gdd„dƒZ e ƒZdd„Zeedddfdd„Zeeddfdd„Zefdd„Zdd„Zdd„Zd:dd „Zd;d!d"„Zd:d#d$„Zdr ©Úselfr r r!Ú__repr__Xóz_Sentinel.__repr__N)Ú__name__Ú __module__Ú __qualname__r-r r r r!r)Ws r)cCsT|tu|tukr tdƒ‚||urtur&n||fS|dur$||jfSdS||fS)Nz-Both or neither of value and tb must be given©NN)Ú _sentinelÚ ValueErrorÚ __traceback__)ÚexcÚvaluer&r r r!Ú_parse_value_tb]sü r8TcCsXt|||ƒ\}}|durtj}tt|ƒ|||dd�}|j|d�D] }t||dd�q dS)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. NT©r$Úcompact©Úchainrr)r8rrrÚtyperr)r6r7r&r$rr<ÚteÚliner r r!r hs ÿr cCs6t|||ƒ\}}tt|ƒ|||dd�}t|j|d�ƒ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(). Tr9r;)r8rr=Úlistr)r6r7r&r$r<r>r r r!r|s rcCs,|tur|}tt|ƒ|ddd�}t| ¡ƒS)aªFormat the exception part of a traceback. 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. NT)r:)r3rr=r@r)r6r7r>r r r!r‹s rcCs0t|ƒ}|dus |sd|}|Sd||f}|S)Nz%s z%s: %s )Ú _some_str)Úetyper7Úvaluestrr?r r r!Ú_format_final_exc_line¡s   ÿrDcCs$zt|ƒWSdt|ƒjYS)Nz)Ústrr=r/)r7r r r!rA©s rAcCstt ¡|||dœŽdS)z>Shorthand for 'print_exception(*sys.exc_info(), limit, file)'.©r$rr<N)r rÚexc_inforFr r r!r ±ór cCsd tt ¡||dœŽ¡S)z%Like print_exc() but return a string.r©r$r<)ÚjoinrrrGrIr r r!r µrHr cCs.ttdƒs tdƒ‚ttjtjtj|||ƒdS)znThis is a shorthand for 'print_exception(sys.last_type, sys.last_value, sys.last_traceback, limit, file)'.Ú last_typezno last exceptionN)Úhasattrrr4r rKÚ last_valueÚlast_tracebackrFr r r!r ¹s ÿr cCs*|dur t ¡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$rr r r!r Ås r cCs"|dur t ¡j}tt||d�ƒS)z5Shorthand for 'format_list(extract_stack(f, limit))'.Nr#)rrOrPrr)rQr$r r r!rÑs rcCs0|dur t ¡j}tjt|ƒ|d�}| ¡|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#)rrOrPrr(rÚreverse)rQr$Ústackr r r!rØs  rcCs@|durz|j ¡Wn tyYnw|j}|dusdSdS)zEClear all references to local variables in the frames of a traceback.N)Útb_frameÚclearÚ RuntimeErrorÚtb_next©r&r r r!rès þúrc@sZeZdZdZdZddddœdd„Zdd „Zd d „Zd d „Zdd„Z dd„Z e dd„ƒZ dS)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ÚlocalsTN)Ú lookup_liner]r?cCsH||_||_||_||_|r|j|rdd„| ¡Dƒ|_dSd|_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. cSsi|] \}}|t|ƒ“qSr )Úrepr)Ú.0ÚkÚvr r r!Ú sz)FrameSummary.__init__..N)rYrZr[r\r?Úitemsr])r,rYrZr[r^r]r?r r r!Ú__init__s &zFrameSummary.__init__cCs`t|tƒr|j|jko|j|jko|j|jko|j|jkSt|tƒr.|j|j|j|jf|kStS©N) Ú isinstancerrYrZr[r]Útupler?ÚNotImplemented©r,Úotherr r r!Ú__eq__s   ÿ þ ý zFrameSummary.__eq__cCs|j|j|j|jf|Srf)rYrZr[r?)r,Úposr r r!Ú __getitem__ ózFrameSummary.__getitem__cCst|j|j|j|jgƒSrf)ÚiterrYrZr[r?r+r r r!Ú__iter__#rozFrameSummary.__iter__cCsdj|j|j|jd�S)Nz7)rYrZr[)rrYrZr[r+r r r!r-&s ÿzFrameSummary.__repr__cCr*)Nér r+r r r!Ú__len__*r.zFrameSummary.__len__cCs4|jdur|jdur dSt |j|j¡|_|j ¡Srf)r\rZÚ linecacheÚgetlinerYÚstripr+r r r!r?-s   zFrameSummary.line) r/r0r1Ú__doc__Ú __slots__rerlrnrqr-rsÚpropertyr?r r r r!rós  ÿ rccs@�|dur t ¡jj}|dur||jfV|j}|dusdSdS)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)rrOrPÚf_lineno)rQr r r!r5s€  þrccs.�|dur|j|jfV|j}|dusdSdS)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)rTÚ tb_linenorWrXr r r!rBs €þréc@s:eZdZdZeddddœdd„ƒZedd „ƒZd d „ZdS) rzA stack of frames.NTF©r$Ú lookup_linesÚcapture_localsc Csî|durttddƒ}|dur|dkrd}|dur+|dkr#t ||¡}ntj|| d�}|ƒ}tƒ}|D]-\}}|j} | j} | j } |  | ¡t   | |j ¡|rR|j} nd} | t| || d| d�¡q3|D]} t  | ¡qc|ru|D]}|jqo|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)ÚmaxlenF)r^r])ÚgetattrrÚ itertoolsÚisliceÚ collectionsÚdequeÚsetÚf_codeÚ co_filenameÚco_nameÚaddrtÚ lazycacheÚ f_globalsÚf_localsÚappendrÚ checkcacher?) ÚklassÚ frame_genr$r~rÚresultÚfnamesrQrZÚcorYr[rŽr r r!r(Rs8     ÿ zStackSummary.extractc CsLtƒ}|D]}t|tƒr| |¡q|\}}}}| t||||d�¡q|S)z€ Create a StackSummary object from a supplied list of FrameSummary objects or old-style list of tuples. )r?)rrgrr�)r‘Úa_listr“ÚframerYrZr[r?r r r!r‚s    zStackSummary.from_listc Csdg}d}d}d}d}|D]‰}|dus)||jks)|dus)||jks)|dus)||jkrN|tkrC|t8}| d|›d|dkr=dnd›d�¡|j}|j}|j}d}|d7}|tkrWq g}| d  |j|j|j¡¡|jrt| d  |j ¡¡¡|jr�t |j  ¡ƒD]\}} | d j|| d �¡q~| d  |¡¡q |tkr°|t8}| d|›d|dkrªdnd›d�¡|S) aFormat 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. Nrz [Previous line repeated z more timeéÚsrz] z File "{}", line {}, in {} ú {} z {name} = {value} )r[r7) rYrZr[Ú_RECURSIVE_CUTOFFr�rr?rvr]ÚsortedrdrJ) r,r“Ú last_fileÚ last_lineÚ last_nameÚcountr—Úrowr[r7r r r!r•sR ÿÿ ÿÿÿzStackSummary.format)r/r0r1rwÚ classmethodr(rrr r r r!rOsÿ/  rc@sheZdZdZddddddœdd„Zedd „ƒZd d „Zd d „Zdd„Z dd„Z dd„Z ddœdd„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:`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~rr:Ú_seenc Csî|du} |dur tƒ}| t|ƒ¡tjt|ƒ|||d�|_||_t|ƒ|_ |r]t |t ƒr]|j |_ |j } | durÚeÚcauseÚ need_contextÚcontextr r r!reésŒ þ ÿ  ù ÿþÿù ÚþzTracebackException.__init__cOs |t|ƒ||jg|¢Ri|¤ŽS)z.Create a TracebackException from an exception.)r=r5)Úclsr6ÚargsÚkwargsr r r!Úfrom_exception9s z!TracebackException.from_exceptioncCs|jD]}|jqdS)z7Private API. force all lines in the stack to be loaded.N)rSr?)r,r—r r r!r®>s ÿzTracebackException._load_linescCst|tƒr |j|jkStSrf)rgrÚ__dict__rirjr r r!rlCs  zTracebackException.__eq__cCs|jSrf)r¦r+r r r!Ú__str__HszTracebackException.__str__ccs‚�|jdurtd|jƒVdS|jj}|jj}|dvr(t|tƒs"d}|d|}t|jtƒs7t||jƒVdS|  |¡EdHdS)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 emits 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__Úbuiltinsz Ú.) r¥rDr¦r1r0rgrEr§r¨Ú_format_syntax_error)r,ÚstypeÚsmodr r r!rKs€    z(TracebackException.format_exception_onlyc cs,�d}|jdurd |jpd|j¡Vn |jdurd |j¡}|j}|dur‡| d¡}| d¡}t|ƒt|ƒ}d |¡V|jdur‡|j}|jd vrN|jn|}||ksX|d kr\|d }|d |} |d |} | d kr‡d d„|d| …Dƒ} d d  | ¡d| | d¡V|j p‹d} d || |¡VdS)z0Format SyntaxError exceptions (internal helper).rNz File "{}", line {} zz ({})Ú z rš>Nréÿÿÿÿr˜rcss �|] }| ¡r |ndVqdS)ú N)Úisspace)r`Úcr r r!Ú ‡s€z:TracebackException._format_syntax_error..z {}{}ú^zz {}: {}{} ) rZrrYrªÚrstripÚlstripÚlenr«r¬rJr­) r,rÇÚfilename_suffixrªÚrtextÚltextÚspacesr«r¬ÚcolnoÚ end_colnoÚ caretspacer­r r r!rÆhs4€  ÿ          z'TracebackException._format_syntax_errorr;ccsÄ�g}|}|r;|r0|jdurt}|j}n|jdur"|js"t}|j}nd}d}| ||f¡|}n | d|f¡d}|st|ƒD] \}}|durJ|V|jrXdV|j ¡EdH|  ¡EdHq?dS)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. Nz#Traceback (most recent call last): ) r±Ú_cause_messager²r¯Ú_context_messager�ÚreversedrSrr)r,r<Úoutputr6Ú chained_msgÚ chained_excr­r r r!rŒs8€   ÿïúzTracebackException.format) r/r0r1rwrer¢rÀr®rlrÂrrÆrr r r r!rÉs þP $rrfr2)NNT)NT)NNN)#rwr…rƒrtrÚ__all__r"rrrrrÚrÛr)r3r8r rrrDrAr r r r rrrrrrr›r@rrr r r r!ÚsP   ÿÿ  ÿ ÿ      B  z