Format: application/x-python-code
⬇ Download File (11.9 KB)
   1  o
   2  
   3  0'h�Q�@s ddlmZddlZddlZddlZddlZddlmZddl	m
   4  Z
   5  ddlmZm
   6  Z
   7  mZddlmZdZd	Zd
   8  ZdZdd
   9  �Zefdd�ZGdd�d�ZdDdd�ZGdd�dej�ZejjZejjZe ejdd�Z!ej"ej#ur�ej$ej_$ejej_ejej_ee_"e ej"dd�d vr�ej$ej_$ejej_ejej_dd!l	m%Z%ddl&Z&e%d"�Z'e'j(�)ej(�ee'_#e'e&_edEd%d&��Zej*dFd(d)��Z+e		*dGdHd/d0��Z,e,j*		*dGdId2d)��Z+e			*dJdKd5d6��Z-e-j*			*dJdLd7d)��Z+			*dJdMd9d:�Z.d;Z/d<Z0d=Z1dZ2e3�Z4d>d?�Z5d@dA�Z6dBdC�Z7dS)N�)�annotationsN)�singledispatch)�
  10  TracebackType)�Any�List�Optional�)�BaseExceptionGroup��
  11  zG
  12  The above exception was the direct cause of the following exception:
  13  
  14  zF
  15  During handling of the above exception, another exception occurred:
  16  
  17  cCs8t|d�}|dus|s|�d�}|S|�d|�d�}|S)N�	exception�
  18  z: )�_safe_string)�etype�value�valuestr�line�r�PC:\Users\shubh\Videos\agent\nova\Lib\site-packages\exceptiongroup/_formatting.py�_format_final_exc_lines
  19  
  20  �rcCs2z||�WStyd|�d|j�d�YSw)N�<� z
  21  () failed>)�
  22  BaseException�__name__)r�what�funcrrrr&s
  23  
  24  �rc@s&eZdZdd�Zdd�Zddd�ZdS)	�_ExceptionPrintContextcCst�|_d|_d|_dS)NrF)�set�seen�exception_group_depth�
  25  need_close��selfrrr�__init__.s
  26  z_ExceptionPrintContext.__init__cCsdd|jS)Nr�)rr!rrr�indent3sz_ExceptionPrintContext.indentNccsl�|durd}|��}|jr||d7}t|t�r%t�||dd��VdS|D]}t�||dd��Vq'dS)N�|rcS�dS�NTr�rrrr�<lambda>>�z-_ExceptionPrintContext.emit.<locals>.<lambda>cSr'r(rr)rrrr*Ar+)r%r�
  27  isinstance�str�textwrap)r"Ztext_gen�margin_charZ
  28  indent_str�textrrr�emit6s�
  29  �z_ExceptionPrintContext.emit�N)r�
  30  __module__�__qualname__r#r%r1rrrrr-srr�type[BaseException]rr�tb�TracebackType | None�return�Nonec	Cs tj�d�t�|||���dS)N�)�sys�stderr�write�join�	traceback�format_exception)rrr6rrr�exceptiongroup_excepthookDs rAc@s<eZdZdddddd�ddd�Zddd�dd�Zdd�ZdS)�PatchedTracebackExceptionNTF)�limit�lookup_lines�capture_locals�compact�_seen�exc_typer5�	exc_valuer�
  31  exc_tracebackr7rC�
  32  int | NonerD�boolrErFrG�set[int] | Noner8r9c	CsRi}	tjdkr||	d<|du}
  33  |durt�}|�t|��tjjt�|�|||d�|_	||_
  34  t|d�|_z	t
  35  |dd�|_Wn'tydt
  36  tj�dd�dd�}tjdd	�d
  37  krat||�rad|_n�Ynw|r�t|t�r�|j|_|j}|dur{t|�nd|_|j|_|j|_|j|_tjdkr�|j}
  38  |
  39  dur�t|
  40  �nd|_|j|_n#|r�t|ttf�r�t
  41  |dd�dur�t||�}|r�|jd|�d
  42  �7_|r�|j	D]}|j q�|dur�|j!nd|_!|
  43  �s�||fg}|�r�|�"�\}}|�r|j#du�rt|j#�|v�rt$t%|j#�|j#|j#j&||||d�}nd}|�r"|du�o |du�o |j!}nd}|�rJ|j'du�rJ|�rJt|j'�|v�rJt$t%|j'�|j'|j'j&||||d�}nd}|�rqt|t(��rqg}|j)D]}t$t%|�||j&|||d�}|�*|��qZnd}||_#||_'||_)|�r�|�*|j#|j#f�|�r�|�*|j'|j'f�|�r�|�+t,|j)|j)��|s�dSdSdS)N)�rrF)rCrDrEr�	__notes__zurllib.error�	HTTPErrorrr$)rN��namez. Did you mean: 'z'?F)rCrDrErGT)rDrErG)-r;�version_infor�add�idr?�StackSummary�extract�walk_tb�stackrHr�_str�getattrrO�KeyError�modules�getr,�
  44  issubclass�SyntaxError�filename�linenor-r0�offset�msg�
  45  end_lineno�
  46  end_offset�	NameError�AttributeError�_compute_suggestion_errorr�__suppress_context__�pop�	__cause__rB�type�
  47  __traceback__�__context__r	�
  48  exceptions�append�extend�zip)r"rHrIrJrCrDrErFrG�kwargs�is_recursive_callrP�lno�end_lno�
  49  suggestion�frame�queue�te�e�cause�need_context�contextrp�excZtexcrrrr#Ks�
  50  ���	
  51  ���
  52  
  53  �
  54  "�
  55  ����
  56  
  57  ����z"PatchedTracebackException.__init__��chain�_ctxc	cs��|durt�}g}|}|r9|r8|jdurt}|j}n|jdur)|js)t}|j}nd}d}|�||f�|}|sn|�d|f�t|�D�]#\}}|durU|�|�EdH|j	dur{|j
  58  rp|�d�EdH|�|j
  59  ���EdH|�|���EdHqD|j
  60  tkr�|�dt�d��EdHqD|j
  61  dk}|r�|j
  62  d7_
  63  |j
  64  r�|jd|r�dndd�EdH|�|j
  65  ���EdH|�|���EdHt|j	�}	|	tkr�|	}
  66  ntd}
  67  d	|_t|
  68  �D]�}||
  69  dk}|r�d
  70  |_tdur�|tk}
  71  nd	}
  72  |
  73  s�|d�nd}|��|dk�rdnd
  74  d|�d�V|j
  75  d7_
  76  |
  77  �s%|j	|j||d�EdHn|	t}|dk�r0dnd}|�d|�d|�d��EdH|�rR|j�rR|��dVd	|_|j
  78  d8_
  79  q�|�rh|j
  80  dk�seJ�d|_
  81  qDdS)Nz#Traceback (most recent call last):
  82  z... (max_group_depth is z)
  83  rrz3Exception Group Traceback (most recent call last):
  84  �+)r/FTz...z+-z  z+---------------- z ----------------
  85  r��sr:zand z more exceptionr
  86  z&+------------------------------------
  87  )rrl�_cause_messagerorj�_context_messagerq�reversedr1rprY�format�format_exception_onlyr�max_group_depth�len�max_group_widthr �ranger%)r"r�r��outputr��chained_msg�chained_excrdZis_toplevelZnum_excs�n�i�last_exc�	truncated�title�	remaining�pluralrrrr��s��
  88  ��
  89  
  90  
  91  
  92  �
  93  
  94  �
  95  ��
  96  ���z PatchedTracebackException.formatccs��|jdurt�d|j�VdS|jj}|jj}|dvr)t|t�s#d}|d|}t|jt	�s7t||j�Vnt
  97  durDt
  98  ||�EdHnt|�EdHt|jt
  99  jj�rm|jD]}t|d�}dd�|�d�D�EdHqVdS|jdur}t|jd	td
 100  �VdSdS)a�Format the exception part of the traceback.
 101          The return value is a generator of strings, each ending in a newline.
 102          Normally, the generator emits a single string; however, for
 103          SyntaxError exceptions, it emits several lines that (when
 104          printed) display detailed information about where the syntax
 105          error occurred.
 106          The message indicating which exception occurred is always the last
 107          string in the output.
 108          N)�__main__�builtinsz	<unknown>�.�notecSsg|]}|d�qS)r
 109  r)�.0rrrr�
 110  <listcomp>RszCPatchedTracebackException.format_exception_only.<locals>.<listcomp>r
 111  rO)r)rHr?rrZr4r3r,r-r_r`�'traceback_exception_format_syntax_error�2traceback_exception_original_format_exception_onlyrO�collections�abc�Sequencer�split�repr)r"�stype�smodr�rrrr�3s.�
 112  
 113  
 114  
 115  
 116  �
 117  �z/PatchedTracebackException.format_exception_only)rHr5rIrrJr7rCrKrDrLrErLrFrLrGrMr8r9)rr3r4r#r�r�rrrrrBJs�YrB�_format_syntax_errorr)Zapport_excepthookZpartial_apport_excepthook)�
 118  ModuleTypeZexceptiongroup_fake_sys�__exc�	List[str]cCsttt|�|ddd����S)NT)rF)�listrBrmr�)r�rrrr��s��r�rmcCst|�Sr2)r�)r�rrrr�_�sr�TrC�
 119  Optional[int]r�rLcCs$ttt|�||j|dd�j|d��S)NT)rCrF�r�)r�rBrmrnr�)r�rCr�rrrr@�s���r@rcCst|||�Sr2)r@)r�rr6rCr�rrrr��s�filercCsD|durtj}tt|�||j|d�j|d�D]	}t||dd�qdS)N)rCr�r:)r��end)r;r<rBrmrnr��print)r�rCr�r�rrrr�print_exception�s�
 120  ��r�cCst||||�dSr2)r�)r�rr6rCr�r�rrrr��s	�
 121  Any | NonecCst��d}t||||�dS)Nr)r;�exc_infor�)rCr�r�rrrr�	print_exc�sr�i��(r$cCs$||krdS|��|��krtStS)Nr)�lower�
 122  _CASE_COST�
 123  _MOVE_COST)Zch_aZch_brrr�_substitution_cost�s
 124  r�cCsXt|dd�}|dust|t�sdSt|t�r6t|dt�}|tur"dS|j}zt|�}Wn6ty5YdSwt|t�s=J�|durCdS|j	durP|j	}|j	dusH|j
 125  }t|j�t|j
 126  �t|j�}t|�tkrjdSt|�}|tkrtdS|}d}|D]/}	|	|kr�qzt|	�|dtd}
 127  t|
 128  |d�}
 129  t||	|
 130  �}||
 131  kr�qz|r�||kr�|	}|}qz|S)NrR�objrN�r)r[r,r-rh�	_SENTINELr��dir�	Exceptionrg�tb_next�tb_framer��f_locals�	f_globals�
 132  f_builtinsr��_MAX_CANDIDATE_ITEMS�_MAX_STRING_SIZEr��min�_levenshtein_distance)rIr6Z
 133  wrong_namer��dryZwrong_name_lenZ
 134  best_distancerxZ
 135  possible_nameZmax_distanceZcurrent_distancerrrri�sV
 136  �
 137  
 138  ���ricCsR||krdSd}||d�r4||d�r4||||kr4|d7}||d�r4||d�r4||||ks||d�}||d�}d}|d|pGd�r~|d|pOd�r~||d||dkr~|d8}|d|pgd�r~|d|pod�r~||d||dks^|d|p�d�}|d|p�d�}|r�|s�tt|�t|�St|�tks�t|�tkr�|dSt|�t|�kr�||}}t|�t|�t|kr�|dSttttt|�dt��}d}tt|��D]G}||}|t}	}tj}
 139  tt|��D]&}|	t|||�}||}	t||	�t}
 140  t|
 141  |�}|||<||
 142  k�r|}
 143  q�|
 144  |k�r&|dSq�|S)Nrr)	r�r�r�r�r�r;�maxsizer�r�)�a�bZmax_cost�pre�post�row�resultZbindexZbcharZdistance�minimum�index�
 145  substituteZ
 146  insert_deleterrrr�sR((�88�
 147  
 148  
 149  �
 150  �r�)rr5rrr6r7r8r9)r�rr8r�)r�rmrrr8r�r()r�rrCr�r�rLr8r�)r�rmrrr6rrCr�r�rLr8r�)NNT)
 151  r�rrCr�r�rr�rLr8r9)r�rmrrr6rrCr�r�rr�rLr8r9)rCr�r�r�r�rLr8r9)8�
 152  __future__r�collections.abcr�r;r.r?�	functoolsr�typesr�typingrrr�_exceptionsr	r�r�r�r�rr-rrrA�TracebackExceptionrBr�Z#traceback_exception_original_formatr�r�r[r��
 153  excepthook�__excepthook__r#r�Zapport_python_hookZfake_sys�__dict__�update�registerr�r@r�r�r�r�r�r��objectr�r�rir�rrrr�<module>s���
 154  
 155  ����������
 156  ���1