HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/.local/lib/python3.10/site-packages/exceptiongroup/__pycache__/_catch.cpython-310.pyc
o

���gH�@s�ddlmZddlZddlZddlmZmZmZddlm	Z	ddl
mZddlm
Z
mZejdkr7dd	lmZe
rBeeegefZGd
d�d�Zddd�ZdS)�)�annotationsN)�Callable�Iterable�Mapping)�AbstractContextManager)�
TracebackType)�
TYPE_CHECKING�Any)���)�BaseExceptionGroupc@s4eZdZddd�Zddd�Zddd�Zddd�ZdS)�_Catcher�handler_map�2Mapping[tuple[type[BaseException], ...], _Handler]cCs
||_dS�N)�_handler_map)�selfr�r�H/home/arjun/.local/lib/python3.10/site-packages/exceptiongroup/_catch.py�__init__s
z_Catcher.__init__�return�NonecCsdSrr)rrrr�	__enter__sz_Catcher.__enter__�etype�type[BaseException] | None�exc�BaseException | None�tb�TracebackType | None�boolcCs`|dur.|�|�}||urdS|durdSt|t�r+z||j�ty*|j|_�w||�dS)NFT)�handle_exception�
isinstancer
�	__cause__�__context__)rrrr�	unhandledrrr�__exit__s

�z_Catcher.__exit__�
BaseExceptionc	CsPt|t�r|}ntd|g�}g}|j��D]m\}}|�|�\}}|r~zz|�ty2||�}YnwWn8tyV}z||urF|�|�n|�|j�WYd}~n,d}~wtyl}z|�|�WYd}~nd}~wwt	�
|�r~td|�d|�d��|�|s�nq|r�t|�dkr�|dStd|�S|r�t|j�dkr�|jd|ur�|S|S)N�zError trying to handle z with z,. Exception handler must be a sync function.rr)
r"r
r�items�split�append�extend�
exceptionsr'�inspect�iscoroutine�	TypeError�len)	rr�excgroup�new_exceptions�	exc_types�handler�matched�result�new_excrrrr!2sR
����
���
�z_Catcher.handle_exceptionN)rr)rr)rrrrrrrr )rr'rr)�__name__�
__module__�__qualname__rrr&r!rrrrrs



r�
__handlers�FMapping[type[BaseException] | Iterable[type[BaseException]], _Handler]r�AbstractContextManager[None]cCs�t|t�s	td��i}|��D]H\}}t|t�r!t|t�r!|f}nt|t�r+t|�}ntd��t	|�s7td��|D]}t|t�rEt|t�sItd��t|t
�rRtd��q9|||<qt|�S)Nzthe argument must be a mappingzCeach key must be either an exception classes or an iterable thereofzhandlers must be callablezHcatching ExceptionGroup with catch() is not allowed. Use except instead.)r"rr0r)�type�
issubclassr'r�tuple�callabler
r)r<r�type_or_iterabler5�iterable�exc_typerrr�catch`s<
��

���
��
rF)r<r=rr>)�
__future__rr.�sys�collections.abcrrr�
contextlibr�typesr�typingrr	�version_info�_exceptionsr
�_HandlerrrFrrrr�<module>s
O