HEX
Server: nginx/1.28.0
System: Linux server-one 5.15.0-153-generic #163-Ubuntu SMP Thu Aug 7 16:37:18 UTC 2025 x86_64
User: root (0)
PHP: 8.3.23
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/rich/__pycache__/traceback.cpython-310.pyc
o

.��fYs�!@s�ddlmZddlZddlZddlZddlZddlmZmZddl	m
Z
ddlmZm
Z
ddlmZmZmZmZmZmZmZmZmZmZddlmZddlmZmZmZmZm Z m!Z!dd	lm"Z#dd
lm$Z$ddl%m&Z&dd
l'm(Z(ddl)m*Z*ddl+m,Z,ddl-m.Z.m/Z/m0Z0m1Z1m2Z2ddl3m4Z4ddl5m6Z6m7Z7ddl8m9Z9ddl:m;Z;ddl<m=Z=ddl>m?Z?dd	l@m"Z"ddlAmBZBe�C�dkZDdZEdZFddddddeEeFdddddd �
d!ee.d"eeGd#eGd$eeHd%eId&eId'eGd(eGd)eId*eeId+eId,eeeHefd-eGd.eeeJeJee
geffd/d0�ZKeGd1d2�d2��ZLeGd3d4�d4��ZMeGd5d6�d6��ZNeGd7d8�d8��ZOGd9d:�d:e6�ZPGd;d<�d<�ZQeRd=k�rrdd>l-m.Z.e.�Z-ddlZd?ed.dfd@dA�ZSd?ed.dfdBdC�ZTdFdDdE�ZUeU�dSdS)G�)�absolute_importN)�	dataclass�field)�walk_tb)�
ModuleType�
TracebackType)
�Any�Callable�Dict�Iterable�List�Optional�Sequence�Tuple�Type�Union)�guess_lexer_for_filename)�Comment�Keyword�Name�Number�Operator�String)�Text)�Token)�
ClassNotFound�)�pretty)�	loop_last)�Columns)�Console�ConsoleOptions�ConsoleRenderable�RenderResult�group)�	Constrain)�RegexHighlighter�ReprHighlighter)�Panel)�render_scope)�Style)�Syntax)�Theme�Windows�
�P�d�FT�)
�console�width�extra_lines�theme�	word_wrap�show_locals�locals_max_length�locals_max_string�locals_hide_dunder�locals_hide_sunder�
indent_guides�suppress�
max_framesr3r4r5r6r7r8r9r:r;r<r=r>r?�returnc
s�|dur	tdd�n|��jr�durdn��dttdtdttddf���������	�
���
f
dd	��d
tddf�fdd�}
zt�}|
|�tj	WSt
y\tj	}�t_	|YSw)
a"Install a rich traceback handler.

    Once installed, any tracebacks will be printed with syntax highlighting and rich formatting.


    Args:
        console (Optional[Console], optional): Console to write exception to. Default uses internal Console instance.
        width (Optional[int], optional): Width (in characters) of traceback. Defaults to 100.
        extra_lines (int, optional): Extra lines of code. Defaults to 3.
        theme (Optional[str], optional): Pygments theme to use in traceback. Defaults to ``None`` which will pick
            a theme appropriate for the platform.
        word_wrap (bool, optional): Enable word wrapping of long lines. Defaults to False.
        show_locals (bool, optional): Enable display of local variables. Defaults to False.
        locals_max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
            Defaults to 10.
        locals_max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to 80.
        locals_hide_dunder (bool, optional): Hide locals prefixed with double underscore. Defaults to True.
        locals_hide_sunder (bool, optional): Hide locals prefixed with single underscore. Defaults to False.
        indent_guides (bool, optional): Enable indent guides in code and locals. Defaults to True.
        suppress (Sequence[Union[str, ModuleType]]): Optional sequence of modules or paths to exclude from traceback.

    Returns:
        Callable: The previous exception handler that was replaced.

    NT)�stderr�type_�value�	tracebackr@cs6�
�tj|||���	�����t�����d��dS)N�r4r5r6r7r8r9r:r;r<r=r>r?)�print�	Traceback�from_exception�bool)rBrCrD)
r5r=r;r<r9r:r?r8r>r6�traceback_consoler4r7r2�9/usr/local/lib/python3.10/dist-packages/rich/traceback.py�
excepthookas&��zinstall.<locals>.excepthook�ipc	sli��j�dtdtddf��fdd�}dd�dtdtdtddf���fd	d
����_|�_�fdd��_dS)
N�args�kwargsr@cs|��|i|��dS)zEwrap the default ip.showtraceback to store info for ip._showtracebackNr2�rNrO)�default_showtraceback�tb_datar2rK�ipy_show_traceback~szCinstall.<locals>.ipy_excepthook_closure.<locals>.ipy_show_tracebackF)�	is_syntaxrTcst���}|rdn|d}��dd�}��d|rdnd�}t|�D]}|dur(n|j}q �|d|d|�i�dS)z2Internally called traceback from ip._showtracebackN��running_compiled_codeF�	tb_offsetrr)�
_get_exc_info�get�range�tb_next)rTrNrO�	exc_tuple�tb�compiledrW�_)rLrMrRr2rK�ipy_display_traceback�szFinstall.<locals>.ipy_excepthook_closure.<locals>.ipy_display_tracebackcs�|ddi|��S)NrTTr2rP)r`r2rK�<lambda>�s���z9install.<locals>.ipy_excepthook_closure.<locals>.<lambda>)�
showtracebackrrI�_showtraceback�showsyntaxerror)rMrS)rL)rQrMr`rRrK�ipy_excepthook_closurezs �����z'install.<locals>.ipy_excepthook_closure)r �
is_jupyterr�
BaseExceptionr
rr�get_ipython�sysrL�	Exception)r3r4r5r6r7r8r9r:r;r<r=r>r?rerM�old_excepthookr2)rLr5r=r;r<r9r:r?r8r>r6rJr4r7rK�install0s4)������&�)�rlc@sLeZdZUeed<eed<eed<dZeed<dZee	ee
jfed<dS)�Frame�filename�lineno�name��lineN�locals)�__name__�
__module__�__qualname__�str�__annotations__�intrrrsr
r
r�Noder2r2r2rKrm�s
rmc@s6eZdZUeed<eed<eed<eed<eed<dS)�_SyntaxError�offsetrnrrro�msgN)rtrurvryrxrwr2r2r2rKr{�s
r{c@sPeZdZUeed<eed<dZeeed<dZe	ed<e
ed�Ze
eed<dS)	�Stack�exc_type�	exc_valueN�syntax_errorF�is_cause)�default_factory�frames)rtrurvrwrxr�r
r{r�rIr�listr�rrmr2r2r2rKr~�s
r~c@seZdZUeeed<dS)�Trace�stacksN)rtrurvrr~rxr2r2r2rKr��s
r�c@seZdZdgZdS)�PathHighlighterz(?P<dim>.*/)(?P<bold>.+)N)rtrurv�
highlightsr2r2r2rKr��s
r�c"@s�eZdZdZdddddd�Z	d4dd	dd
d
eedd
dddd
�deedee	de	dee
dedede	de	dedededee
e
efde	fdd�Zedd	dd
d
eedd
dddd
�deededeedee	de	dee
dedede	de	dedededee
e
efde	d df d!d"��Zed
eedd
d#�deededeedede	de	deded efd$d%��Zd&ed'ed efd(d)�Ze�d*ed efd+d,��Zed-e
d.e
d e
fd/d0��Ze�d1ed efd2d3��Z dS)5rGa�A Console renderable that renders a traceback.

    Args:
        trace (Trace, optional): A `Trace` object produced from `extract`. Defaults to None, which uses
            the last exception.
        width (Optional[int], optional): Number of characters used to traceback. Defaults to 100.
        extra_lines (int, optional): Additional lines of code to render. Defaults to 3.
        theme (str, optional): Override pygments theme used in traceback.
        word_wrap (bool, optional): Enable word wrapping of long lines. Defaults to False.
        show_locals (bool, optional): Enable display of local variables. Defaults to False.
        indent_guides (bool, optional): Enable indent guides in code and locals. Defaults to True.
        locals_max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
            Defaults to 10.
        locals_max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to 80.
        locals_hide_dunder (bool, optional): Hide locals prefixed with double underscore. Defaults to True.
        locals_hide_sunder (bool, optional): Hide locals prefixed with single underscore. Defaults to False.
        suppress (Sequence[Union[str, ModuleType]]): Optional sequence of modules or paths to exclude from traceback.
        max_frames (int): Maximum number of frames to show in a traceback, 0 for no maximum. Defaults to 100.

    �text�python�cython�pyrex)rqz.pyz.pxdz.pyxz.pxiNr0r1FTr2rE�tracer4r5r6r7r8r9r:r;r<r=r>r?cCs|dur$t��\}}}|dus|dus|durtd��|j||||d�}||_||_||_t�|p2d�|_	||_
||_||_||_
||_|	|_|
|_g|_|D]-}t|t�sj|jdusbJ|�d���tj�|j�}n|}tj�tj�|��}|j�|�qO|
dkr�td|
�|_dSd|_dS)Nz9Value for 'trace' required if not called in except: block�r8�	ansi_darkz+ must be a module with '__file__' attributer�)ri�exc_info�
ValueError�extractr�r4r5r+�	get_themer6r7r8r=r9r:r;r<r>�
isinstancerw�__file__�os�path�dirname�normpath�abspath�append�maxr?)�selfr�r4r5r6r7r8r9r:r;r<r=r>r?rr�rD�suppress_entityr�r2r2rK�__init__�s>��
�"zTraceback.__init__rr�rDr@cCs<|j|||||	|
||d�}||||||||
|	|
||||d�
S)aeCreate a traceback from exception info

        Args:
            exc_type (Type[BaseException]): Exception type.
            exc_value (BaseException): Exception value.
            traceback (TracebackType): Python Traceback object.
            width (Optional[int], optional): Number of characters used to traceback. Defaults to 100.
            extra_lines (int, optional): Additional lines of code to render. Defaults to 3.
            theme (str, optional): Override pygments theme used in traceback.
            word_wrap (bool, optional): Enable word wrapping of long lines. Defaults to False.
            show_locals (bool, optional): Enable display of local variables. Defaults to False.
            indent_guides (bool, optional): Enable indent guides in code and locals. Defaults to True.
            locals_max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
                Defaults to 10.
            locals_max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to 80.
            locals_hide_dunder (bool, optional): Hide locals prefixed with double underscore. Defaults to True.
            locals_hide_sunder (bool, optional): Hide locals prefixed with single underscore. Defaults to False.
            suppress (Iterable[Union[str, ModuleType]]): Optional sequence of modules or paths to exclude from traceback.
            max_frames (int): Maximum number of frames to show in a traceback, 0 for no maximum. Defaults to 100.

        Returns:
            Traceback: A Traceback instance that may be printed.
        �r8r9r:r;r<)r4r5r6r7r8r=r9r:r;r<r>r?)r�)�clsrr�rDr4r5r6r7r8r9r:r;r<r=r>r?�rich_tracebackr2r2rKrH$s2+��zTraceback.from_exceptionr�c	s�g}	d}
ddlm}dtdtfdd�}	t||j�||�|
d	�}
t|t�r<t|j	p*d|j
p.d
|jp2d|jp6d|j
d�|
_|	�|
�|
jj}d
ttttfdttttff��fdd�}t|�D]R\}}|jj}|r}|�d�s}tj�|�s}tj�||�}|j�dd�r�qat|p�d
||jj|r���fdd�||j� ��D�ndd�}||�|j�dd�r�|
jdd�=qat!|dd�}|r�|j"}|}|j#}d}
q|j$}|r�t!|dd�s�|j"}|}|j#}d}
q	t%|	d�}|S)a�Extract traceback information.

        Args:
            exc_type (Type[BaseException]): Exception type.
            exc_value (BaseException): Exception value.
            traceback (TracebackType): Python Traceback object.
            show_locals (bool, optional): Enable display of local variables. Defaults to False.
            locals_max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
                Defaults to 10.
            locals_max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to 80.
            locals_hide_dunder (bool, optional): Hide locals prefixed with double underscore. Defaults to True.
            locals_hide_sunder (bool, optional): Hide locals prefixed with single underscore. Defaults to False.

        Returns:
            Trace: A Trace instance which you can use to construct a `Traceback`.
        Fr)�_IMPORT_CWD�_objectr@cSs zt|�WStyYdSw)z1Don't allow exceptions from __str__ to propagate.z<exception str() failed>)rwrj)r�r2r2rK�safe_str�s

�z#Traceback.extract.<locals>.safe_strT)rr�r��?rq)r|rnrorrr}�iter_localsc3sT��s�s|EdHdS|D]\}}�r|�d�rq�r"|�d�r"q||fVqdS)z-Extract locals from an iterator of key pairs.N�__r_��
startswith)r��keyrC)r;r<r2rK�
get_locals�s�
�z%Traceback.extract.<locals>.get_locals�<�_rich_traceback_omitcs"i|]
\}}|tj|��d��qS))�
max_length�
max_string)r�traverse)�.0r�rC)r9r:r2rK�
<dictcomp>�s���z%Traceback.extract.<locals>.<dictcomp>N)rnrorprs�_rich_traceback_guard�	__cause__�__suppress_context__)r�)&�richr�rrwr~rtr��SyntaxErrorr{r|rnror�r}r�r�r�rr�objectr�f_code�co_filenamer�r�r��isabs�join�f_localsrYrm�co_name�items�getattr�	__class__�
__traceback__�__context__r�)r�rr�rDr8r9r:r;r<r�r�r�r��stackr�r��
frame_summary�line_norn�frame�causer�r2)r;r<r9r:rKr�js~�
�
��	��	��
zTraceback.extractr3�optionsccsR�|j}|��}|j}tid|t��d|t��d|t��d|tj��d|t	��d|t
�tdd��d	|t��d
|t�tdd��d|t	��d
|tj
��d|tj
��d|tj
��d|tj��d|t��d|t��d|tj
�tdd��dd�}t�}tt|jj��D]�\}}	|	jr�t|�|	�d|dddd�}
t|
|j�}
|�|��|
VWd�n1s�wY|	jdur�|�|��tt|�|	j�|ddd|jd�|j�VWd�n1s�wYt�|	j�d�df||	jj ��Vn|	j!�rt�|	j�d�df||	j!��Vn
t�|	j�df�V|�s&|	j"�r t�#d�Vq�t�#d�Vq�dS) Nr�
pygments.text�pygments.string�pygments.function�pygments.numberzrepr.indentT)�dimzrepr.strz
repr.brace)�boldzrepr.numberzrepr.bool_truezrepr.bool_falsez	repr.nonezscope.borderzscope.equalsz	scope.keyzscope.key.specialF)�inheritz7[traceback.title]Traceback [dim](most recent call last)ztraceback.border)rr)�title�style�border_style�expand�paddingztraceback.border.syntax_error)r�r�r�r�r4z: ztraceback.exc_typezI
[i]The above exception was the direct cause of the following exception:
zH
[i]During handling of the above exception, another exception occurred:
)$r6�get_background_style�get_style_for_tokenr,�	TextTokenrrr�Functionrrr*r�Constant�	Delimiterrr'r�reversedr�r�r�r(�
_render_stackr%r4�	use_themer��_render_syntax_errorr�assemblerr}r�r��from_markup)r�r3r�r6�background_style�token_style�traceback_theme�highlighter�lastr��stack_renderabler2r2rK�__rich_console__�s�����
�����	�

�
�
�

�������

���
������zTraceback.__rich_console__r�ccs��t�}t�}|jdkr,tj�|j�r,tjd|j��dfdt|j	�dfdd�}||�V||j
���}d|_t
|jd	t|��}|�d
||�|tjdd|ddd�7}|VdS)
Nz<stdin>� r���:r�r�r��r�Trzbold underline�
u[traceback.offset]▲[/])r'r�rnr�r��existsrr�rwrorr�rstrip�no_wrap�minr|�len�stylizer�)r�r�r��path_highlighterr��syntax_error_textr|r2r2rKr�5s*�
�
�
zTraceback._render_syntax_errorrn�codecCs�tj�|�d}|s(|�d�}|dkr|d|�n|}|�d�r(d|��vr(dSz
|j�|�p4t||�j	WSt
y?YdSw)N���r�z#!r�r�)r�r��splitext�indexr��lower�LEXERSrYrrpr)r�rnr��ext�new_line_index�
first_liner2r2rK�_guess_lexerLs
�zTraceback._guess_lexerr�c
#sV�t�}�j}dtdtfdd�}dtdttf�fdd�}d}�jdkr4t�jd	t|j	��jd	�}d
}t
|j	�D]�\}}	|rH||vrHd}q;|r`|dusPJ�tdt|��d
�ddd�Vd
}|dk}
|	j�t
�fdd��jD��}tj�|	j�r�tj|t|	jdd��dt|	j�dfd|	jdfdd�}ntjd|	jdfdt|	j�dfdd�}|	j�d�s�|
s�dV|V|	j�d�r�||	�EdHq;|�s(z1||	j�}
|
s�Wq;��|	j|
�}t|
||d|	j�j|	j�jf|	jh�jd�jd
d�
}dVWnt�y}zt�d|��df�VWYd}~q;d}~ww|	j�r%t|g||	��d d!�n|Vq;dS)"Nrnr@cSsd�t�|��S)z�Read files, and cache results on filename.

            Args:
                filename (str): Filename to read

            Returns:
                str: Contents of file
            rq)r��	linecache�getlines)rnr2r2rK�	read_codeas	z*Traceback._render_stack.<locals>.read_coder�c3s,�|jrt|jd�j�j�jd�VdSdS)Nrs)r�r=r�r�)rsr)r=r9r:)r�)r�r2rK�
render_localsls���z.Traceback._render_stack.<locals>.render_localsrrUFTz
... z frames hidden ...�centerztraceback.error)�justifyr�c3s�|]}��|�VqdS�Nr�)r�r�)�frame_filenamer2rK�	<genexpr>�s�z*Traceback._render_stack.<locals>.<genexpr>r�r�r�r�z in r�r�zin r�rq�X)r6�line_numbers�
line_range�highlight_linesr7�
code_widthr=�dedentr�r)r�)r�r6rwrmrr"r?rZr�r��	enumeraterrn�anyr>r�r�r�r�rorpr�rr+r5r7r=rjrsr)r�r�r�r6rr�exclude_frames�excluded�frame_indexr��first�
suppressedr�r��
lexer_name�syntax�errorr2)r
r�rKr�\s��

���	�


��
���
�������zTraceback._render_stackr	)!rtrurv�__doc__r��LOCALS_MAX_LENGTH�LOCALS_MAX_STRINGr
r�ryrwrIrrrr��classmethodrrrgrrHr�r r!r#r�r$r{r�rr~r�r2r2r2rKrG�s
�
��������	�
���
��
�3�������	�
���
������E�������	�
��|��
�NrG�__main__)r �acCsd}t||�dS)Nr)rF)r!�oner2r2rK�bar�sr#cCsd}hd�dd�}t|�dS)NT>�Duncan Idaho�Thufir Hawat�
Paul Atreides�Vladimir Harkonnen)NFT)�
characters�atomic_types)r#)r!r��zedr2r2rK�foo�s
�	r+cCs>zztd�WWdStYWdStjdd�YdS)NrTr�)r+�slfkjsldkfjr3�print_exceptionr2r2r2rKr�sr)r@N)V�
__future__rrr��platformri�dataclassesrrrDr�typesrr�typingrr	r
rrr
rrrr�pygments.lexersr�pygments.tokenrrrrrrrr�r�
pygments.utilrrqr�_loopr�columnsrr3r r!r"r#r$�	constrainr%r�r&r'�panelr(�scoper)r�r*rr+r�r6r,�system�WINDOWSrrryrwrIrgrlrmr{r~r�r�rGrtr#r+rr2r2r2rK�<module>s�0
 ��������	�
���
��
�


	�