ž ¬ÿfÎ.c @sŠdZddlZddlZddddddd d d d d ddg Zdddd„Zddd„Zdd„Zdddd„Zddd „Z ddd„Z dZ dZ dddd„Z ddd+dd „Zdd+dd„Zd d„Zd!d"„Zd#d$„Zddd+d%d „Zdd+d&d „Zddd+d'd „Zdddd(d„Zddd)d„Zddd*d„ZdS(,u@Extract, format and print information about Python stack traces.iNu extract_stacku extract_tbuformat_exceptionuformat_exception_onlyu format_listu format_stacku format_tbu print_excu format_excuprint_exceptionu print_lastu print_stackuprint_tbuu cCs|j||ƒdS(N(uwrite(ufileustru terminator((u./opt/alt/python33/lib64/python3.3/traceback.pyu_print su_printcCss|dkrtj}nxT|D]L\}}}}t|d|||fƒ|rt|d|jƒƒqqWdS(uyPrint the list of tuples as returned by extract_tb() or extract_stack() as a formatted stack trace to the given file.u File "%s", line %d, in %su %sN(uNoneusysustderru_printustrip(uextracted_listufileufilenameulinenounameuline((u./opt/alt/python33/lib64/python3.3/traceback.pyu print_lists  u print_listcCsdg}xW|D]O\}}}}d|||f}|rO|d|jƒ}n|j|ƒq W|S(u²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. u File "%s", line %d, in %s u %s (ustripuappend(uextracted_listulistufilenameulinenounameulineuitem((u./opt/alt/python33/lib64/python3.3/traceback.pyu format_lists c Cs|dkrtj}n|dkrBttdƒrBtj}qBnd}xÇ|dk r|dkso||kr|j}|j}|j}|j}|j }t |d|||fƒt j |ƒt j |||jƒ} | rût |d| jƒƒn|j}|d}qKWdS(uPrint 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. utracebacklimitiu File "%s", line %d, in %su iN(uNoneusysustderruhasattrutracebacklimitutb_frameu tb_linenouf_codeu co_filenameuco_nameu_printu linecacheu checkcacheugetlineu f_globalsustriputb_next( utbulimitufileunufulinenoucoufilenameunameuline((u./opt/alt/python33/lib64/python3.3/traceback.pyuprint_tb-s(   '       cCstt||ƒƒS(u5A shorthand for 'format_list(extract_tb(tb, limit))'.(u format_listu extract_tb(utbulimit((u./opt/alt/python33/lib64/python3.3/traceback.pyu format_tbIsc Csþ|dkr*ttdƒr*tj}q*ng}d}xÁ|dk rù|dks]||krù|j}|j}|j}|j}|j}t j |ƒt j |||j ƒ} | rÄ| j ƒ} nd} |j|||| fƒ|j}|d}q9W|S(uí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. utracebacklimitiiN(uNoneuhasattrusysutracebacklimitutb_frameu tb_linenouf_codeu co_filenameuco_nameu linecacheu checkcacheugetlineu f_globalsustripuappendutb_next( utbulimitulistunufulinenoucoufilenameunameuline((u./opt/alt/python33/lib64/python3.3/traceback.pyu extract_tbMs( '       uF The above exception was the direct cause of the following exception: uE During handling of the above exception, another exception occurred: ccs%|dkrtƒ}n|j|ƒg}|j}|j}|dk r‡||kr‡|jt|d|ƒƒ|jtdfgƒnT|dk rÛ|j rÛ||krÛ|jt|d|ƒƒ|jt dfgƒn|j||pð|j fgƒx$|D]}x|D] }|VqWqWdS(NF( uNoneusetuaddu __context__u __cause__uappendu _iter_chainuFalseu_cause_messageu__suppress_context__u_context_messageu __traceback__(uexcu custom_tbuseenuitsucontextucauseuitux((u./opt/alt/python33/lib64/python3.3/traceback.pyu _iter_chainus$          u _iter_chainc CsØ|dkrtj}n|r0t||ƒ}n||fg}x’|D]Š\}}t|tƒrtt||ƒqFn|ršt|dƒt|||ƒntt |ƒ|ƒ}x|D]}t||dƒq¶WqFWdS(uù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. u"Traceback (most recent call last):uN( uNoneusysustderru _iter_chainu isinstanceustru_printuprint_tbuformat_exception_onlyutype( uetypeuvalueutbulimitufileuchainuvaluesulinesuline((u./opt/alt/python33/lib64/python3.3/traceback.pyuprint_exception‹s     cCs¶g}|rt||ƒ}n||fg}x‚|D]z\}}t|tƒrf|j|dƒq4n|r’|jdƒ|jt||ƒƒn|jtt|ƒ|ƒƒq4W|S(uzFormat 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(). u u#Traceback (most recent call last): (u _iter_chainu isinstanceustruappenduextendu format_tbuformat_exception_onlyutype(uetypeuvalueutbulimituchainulistuvalues((u./opt/alt/python33/lib64/python3.3/traceback.pyuformat_exception§s   c Cs‡|d krt||ƒgS|j}|j}|dkrK|d|}nt|tƒsjt||ƒgSg}|jp|d}t|jƒp‘d}|j d||fƒ|j }|j }|d k r]|j d|j ƒƒ|d k r]|j dƒ} tt| ƒ|ƒd }| d |…jƒ} d d „| Dƒ} |j d dj| ƒƒq]n|jpid} |j d|| fƒ|S(uFormat 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. u__main__ubuiltinsu.uu?u File "%s", line %s u %s u iNcss'|]}|jƒr|pdVqdS(u N(uisspace(u.0uc((u./opt/alt/python33/lib64/python3.3/traceback.pyu êsu(format_exception_only..u %s^ uuu%s: %s (u__main__ubuiltins(uNoneu_format_final_exc_lineu__name__u __module__u issubclassu SyntaxErrorufilenameustrulinenouappendutextuoffsetustripurstripuminulenulstripujoinumsg( uetypeuvalueustypeusmodulinesufilenameulinenoubadlineuoffsetu caretspaceumsg((u./opt/alt/python33/lib64/python3.3/traceback.pyuformat_exception_only¿s2         cCs@t|ƒ}|dks| r,d|}nd||f}|S(Nu%s u%s: %s (u _some_struNone(uetypeuvalueuvaluestruline((u./opt/alt/python33/lib64/python3.3/traceback.pyu_format_final_exc_lineðs   u_format_final_exc_linec Cs.yt|ƒSWndt|ƒjSYnXdS(Nu(ustrutypeu__name__(uvalue((u./opt/alt/python33/lib64/python3.3/traceback.pyu _some_strøsu _some_strc Cs`|dkrtj}nz2tjƒ\}}}t||||||ƒWdd}}}XdS(u>Shorthand for 'print_exception(*sys.exc_info(), limit, file)'.N(uNoneusysustderruexc_infouprint_exception(ulimitufileuchainuetypeuvalueutb((u./opt/alt/python33/lib64/python3.3/traceback.pyu print_excÿs   c CsNz8tjƒ\}}}djt|||||ƒƒSWdd}}}XdS(u%Like print_exc() but return a string.uN(usysuexc_infoujoinuformat_exceptionuNone(ulimituchainuetypeuvalueutb((u./opt/alt/python33/lib64/python3.3/traceback.pyu format_exc s cCs\ttdƒstdƒ‚n|dkr6tj}nttjtjtj|||ƒdS(unThis is a shorthand for 'print_exception(sys.last_type, sys.last_value, sys.last_traceback, limit, file)'.u last_typeuno last exceptionN( uhasattrusysu ValueErroruNoneustderruprint_exceptionu last_typeu last_valueulast_traceback(ulimitufileuchain((u./opt/alt/python33/lib64/python3.3/traceback.pyu print_lasts   c Cs^|dkrDy t‚WqDtk r@tjƒdjj}YqDXntt||ƒ|ƒdS(u÷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(). iN(uNoneuZeroDivisionErrorusysuexc_infoutb_frameuf_backu print_listu extract_stack(ufulimitufile((u./opt/alt/python33/lib64/python3.3/traceback.pyu print_stacks    c CsW|dkrDy t‚WqDtk r@tjƒdjj}YqDXntt||ƒƒS(u5Shorthand for 'format_list(extract_stack(f, limit))'.iN(uNoneuZeroDivisionErrorusysuexc_infoutb_frameuf_backu format_listu extract_stack(ufulimit((u./opt/alt/python33/lib64/python3.3/traceback.pyu format_stack-s    c CsC|dkrDy t‚WqDtk r@tjƒdjj}YqDXn|dkrnttdƒrntj}qnng}d}x¸|dk r4|dks¡||kr4|j}|j }|j }|j }t j |ƒt j|||jƒ}|rÿ|jƒ}nd}|j||||fƒ|j}|d}q}W|jƒ|S(usExtract 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. iutracebacklimitiiN(uNoneuZeroDivisionErrorusysuexc_infoutb_frameuf_backuhasattrutracebacklimituf_linenouf_codeu co_filenameuco_nameu linecacheu checkcacheugetlineu f_globalsustripuappendureverse( ufulimitulistunulinenoucoufilenameunameuline((u./opt/alt/python33/lib64/python3.3/traceback.pyu extract_stack6s2    '       T(u__doc__u linecacheusysu__all__u_printuNoneu print_listu format_listuprint_tbu format_tbu extract_tbu_cause_messageu_context_messageu _iter_chainuTrueuprint_exceptionuformat_exceptionuformat_exception_onlyu_format_final_exc_lineu _some_stru print_excu format_excu print_lastu print_stacku format_stacku extract_stack(((u./opt/alt/python33/lib64/python3.3/traceback.pyus4      ! 1