B nE@s6ddlZddlZddlZddlZdddddddd d d d d dddddddgZd2ddZddZd3ddZd4ddZd5ddZ dZ dZ d6dd Z d7ddZ d dZd!d"Zd#d$Zd8d%d Zd9d&d Zd:d'd Zd;d(d ZdN extract_stack extract_tbformat_exceptionformat_exception_only format_list format_stack format_tb print_exc format_excprint_exception print_last print_stackprint_tb clear_frames FrameSummary StackSummaryTracebackException walk_stackwalk_tbcCs8|dkrtj}x$t|D]}t||ddqWdS)N)fileend)sysstderrr from_listformatprint)extracted_listritemr,/opt/alt/python37/lib/python3.7/traceback.py print_listsr!cCst|S)N)rrr)rrrr rs cCstt||d|ddS)N)limit)r)r!r)tbr"rrrr r-scCst||dS)N)r")rr)r#r"rrr r7scCstjt||dS)N)r")rextractr)r#r"rrr r;s zG The above exception was the direct cause of the following exception: zF During handling of the above exception, another exception occurred: TcCsF|dkrtj}x2tt||||dj|dD]}t||ddq,WdS)N)r")chainr)rr)rrrtyperr)etypevaluer#r"rr%linerrr r Ws cCs ttt||||dj|dS)N)r")r%)listrr&r)r'r(r#r"r%rrr rls cCstt||dS)N)r*rr)r'r(rrr r|scCs.t|}|dks|sd|}n d||f}|S)Nz%s z%s: %s ) _some_str)r'r(valuestrr)rrr _format_final_exc_lines    r-cCs"yt|Sdt|jSdS)Nz)strr&__name__)r(rrr r+sr+cCstt|||ddS)N)r"rr%)r rexc_info)r"rr%rrr r scCsdtt||dS)Nr)r"r%)joinrrr0)r"r%rrr r scCs.ttdstdttjtjtj|||dS)N last_typezno last exception)hasattrr ValueErrorr r2 last_valuelast_traceback)r"rr%rrr r s cCs*|dkrtj}tt||d|ddS)N)r")r)r _getframef_backr!r)fr"rrrr r s cCs"|dkrtj}tt||dS)N)r")rr7r8rr)r9r"rrr rs cCs0|dkrtj}tjt||d}||S)N)r")rr7r8rr$rreverse)r9r"stackrrr rs  cCs<x6|dk r6y|jWntk r,YnX|j}qWdS)N)tb_frameclear RuntimeErrortb_next)r#rrr rs  c@sNeZdZdZddddddZddZd d Zd d Zd dZe ddZ dS)r)filenamelinenoname_linelocalsTN) lookup_linerDr)cCsB||_||_||_||_|r"|j|r8dd|Dnd|_dS)NcSsi|]\}}t||qSr)repr).0kvrrr sz)FrameSummary.__init__..)r@rArBrCr)itemsrD)selfr@rArBrErDr)rrr __init__s zFrameSummary.__init__cCs`t|tr:|j|jko8|j|jko8|j|jko8|j|jkSt|tr\|j|j|j|jf|kStS)N) isinstancerr@rArBrDtupler)NotImplemented)rLotherrrr __eq__s      zFrameSummary.__eq__cCs|j|j|j|jf|S)N)r@rArBr))rLposrrr __getitem__szFrameSummary.__getitem__cCst|j|j|j|jgS)N)iterr@rArBr))rLrrr __iter__szFrameSummary.__iter__cCsdj|j|j|jdS)Nz7)r@rArB)rr@rArB)rLrrr __repr__szFrameSummary.__repr__cCs&|jdkr t|j|j|_|jS)N)rC linecachegetliner@rAstrip)rLrrr r)s zFrameSummary.line) r/ __module__ __qualname__ __slots__rMrRrTrVrWpropertyr)rrrr rs ccs8|dkrtjj}x|dk r2||jfV|j}qWdS)N)rr7r8f_lineno)r9rrr r!s    ccs&x |dk r |j|jfV|j}qWdS)N)r< tb_linenor?)r#rrr r.s c@s6eZdZeddddddZeddZd d ZdS) rNTF)r" lookup_linescapture_localsc Cs|dkr(ttdd}|dk r(|dkr(d}|dk rV|dkrFt||}ntj|| d}|}t}xb|D]Z\}}|j} | j} | j } | | t | |j |r|j} nd} |t| || d| dqhWx|D]} t | qW|rx|D] }|jqW|S)Ntracebacklimitr)maxlenF)rErD)getattrr itertoolsislice collectionsdequesetf_code co_filenameco_nameaddrX lazycache f_globalsf_localsappendr checkcacher)) klass frame_genr"rbrcresultfnamesr9rAcor@rBrrrrr r$>s6     zStackSummary.extractc CsPt}xD|D]<}t|tr&||q |\}}}}|t||||dq W|S)N)r))rrNrrs)rua_listrwframer@rArBr)rrr rns     zStackSummary.from_listc Csxg}d}d}d}d}x$|D]}|dksX||jksX|dksX||jksX|dksX||jkr|tkr|t8}|d|d|dkrdndd|j}|j}|j}d}|d7}|tkrqg}|d|j|j|j|jr|d |j|jr(x0t |j D]\}} |d j|| d qW|d |qW|tkrt|t8}|d|d|dkrhdndd|S) Nrz [Previous line repeated z more timesrz] z File "{}", line {}, in {} z {} z {name} = {value} )rBr() r@rArB_RECURSIVE_CUTOFFrsrr)rZrDsortedrKr1) rLrw last_file last_line last_namecountr{rowrBr(rrr rsD   "zStackSummary.format)r/r[r\ classmethodr$rrrrrr r;s . c@sZeZdZdddddddZeddZd d Zd d Zd dZddZ ddddZ dS)rNTF)r"rbrc_seenc Cs>|dkrt}|t||r\|jdk r\t|j|kr\tt|j|j|jj|d||d}nd}|r|jdk rt|j|krtt|j|j|jj|d||d} nd} ||_||_| |_|r|j nd|_ t j t ||||d|_ ||_t||_|r,t|tr,|j|_t|j|_|j|_|j|_|j|_|r:|dS)NF)r"rbrcr)r"rbrc)rkroid __cause__rr& __traceback__ __context__ exc_traceback__suppress_context__rr$rr;exc_typer+_str issubclass SyntaxErrorr@r.rAtextoffsetmsg _load_lines) rLr exc_valuerr"rbrcrcausecontextrrr rMsT      zTracebackException.__init__cOs|t|||jf||S)N)r&r)clsexcargskwargsrrr from_exception sz!TracebackException.from_exceptioncCs:x|jD] }|jqW|jr&|j|jr6|jdS)N)r;r)rrr)rLr{rrr rs    zTracebackException._load_linescCs |j|jkS)N)__dict__)rLrQrrr rRszTracebackException.__eq__cCs|jS)N)r)rLrrr __str__szTracebackException.__str__c cs|jdkrtd|jVdS|jj}|jj}|dkr@|d|}t|jts^t||jVdS|jpfd}t|j ptd}d ||V|j }|j }|dk rd | V|dk r|d}tt||d}|d|}d d |D}d d |V|jpd }d ||VdS)N)__main__builtins.z?z File "{}", line {} z {}  r|css|]}|r|pdVqdS) N)isspace)rGcrrr Gsz;TracebackException.format_exception_only..z {}^ rzz{}: {} )rr-rr\r[rrr@r.rArrrrZrstripminlenlstripr1r) rLstypesmodr@rAbadliner caretspacerrrr rs2      z(TracebackException.format_exception_only)r%ccs|rT|jdk r*|jj|dEdHtVn*|jdk rT|jsT|jj|dEdHtV|jdk rddV|jEdH|EdHdS)N)r%z#Traceback (most recent call last): ) rr_cause_messagerr_context_messagerr;r)rLr%rrr rLs    zTracebackException.format) r/r[r\rMrrrrRrrrrrrr rs9  -)N)NN)N)N)NNT)NT)NNT)NT)NNT)NNN)NN)NN)rirgrXr__all__r!rrrrrrr rrr-r+r r r r rrrrrrr~r*rrrrrr sD          >  z