o �J�hH�@s�ddlmZddlZddlZddlmZmZmZddlm Z ddl m Z ddl 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�SC:\pinokio\api\whisper-webui.git\app\env\lib\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__)rrrrZ 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~t d|�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) rrZexcgroupZnew_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"rr/r(�type� issubclassr&r�tuple�callabler r)r9rZtype_or_iterabler2�iterable�exc_typerrr�catch`s< � �  � �� �� rB)r9r:rr;)� __future__rr-�sys�collections.abcrrr� contextlibr�typesr�typingrr � version_info� _exceptionsr Z_HandlerrrBrrrr�<module>s     O
Memory