
    /~hH                        d dl mZ d dlZd dlZd dlmZmZmZ d dlm	Z	 d dl
mZ d dlmZmZ ej                  dk  rdd	lmZ ereee   gef   Z G d
 d      Z	 	 	 	 ddZy)    )annotationsN)CallableIterableMapping)AbstractContextManager)TracebackType)TYPE_CHECKINGAny)         )BaseExceptionGroupc                  <    e Zd ZddZddZ	 	 	 	 	 	 	 	 ddZd	dZy)
_Catcherc                    || _         y N)_handler_map)selfhandler_maps     ^/var/www/peopleoo.sandbox-dev.co.uk/venv/lib/python3.12/site-packages/exceptiongroup/_catch.py__init__z_Catcher.__init__   s
    '    c                     y r    )r   s    r   	__enter__z_Catcher.__enter__   s    r   c                    |:| j                  |      }||u ry|yt        |t              r	 ||j                  ||y# t        $ r |j                  |_         w xY w)NFT)handle_exception
isinstancer   	__cause____context__)r   etypeexctb	unhandleds        r   __exit__z_Catcher.__exit__   sx     ?--c2IC"c#56'S]]:  S( .  14	-	s	   > Ac                   t        |t              r|}nt        d|g      }g }| j                  j                         D ]#  \  }}|j	                  |      \  }}|r	 	 ||r# n |rt        |      dk(  r|d   S t        d|      S |r+t        |j                        dk(  r|j                  d   |u r|S |S # t        $ r  ||      }Y nw xY w	 t        j                  |      st        d|d|d      |# t        $ r;}||u r|j                  |       n|j                  |j                         Y d }~d }~wt        $ r}|j                  |       Y d }~d }~ww xY w)N zError trying to handle z with z,. Exception handler must be a sync function.r   r   )r   r   r   itemssplitinspectiscoroutine	TypeErrorappendextend
exceptionsBaseExceptionlen)	r   r"   excgroupnew_exceptions	exc_typeshandlermatchedresultnew_excs	            r   r   z_Catcher.handle_exception2   s   c-.H)"se4H.0"&"3"3"9"9"; 	Iw (y 9GX#2%" /	2 >"a'%a((%b.99X001Q68;N;Nq;QUX;XJO; . 2!(!12 **62'5g[wk RI I  ## * B')&--g6&--g.@.@A$ 3"))'223s<   B33CC4CC44	E=1D33E?EEN)r   z2Mapping[tuple[type[BaseException], ...], _Handler])returnNone)r!   ztype[BaseException] | Noner"   BaseException | Noner#   zTracebackType | Noner9   bool)r"   r0   r9   r;   )__name__
__module____qualname__r   r   r%   r   r   r   r   r   r      s<    () " !	
 
4+r   r   c                   t        | t              st        d      i }| j                         D ]  \  }}t        |t              rt        |t              r|f}n't        |t              rt        |      }nt        d      t        |      st        d      |D ]H  }t        |t              rt        |t              st        d      t        |t              s?t        d       |||<    t        |      S )Nzthe argument must be a mappingzCeach key must be either an exception classes or an iterable thereofzhandlers must be callablezHcatching ExceptionGroup with catch() is not allowed. Use except instead.)r   r   r,   r(   type
issubclassr0   r   tuplecallabler   r   )
__handlersr   type_or_iterabler5   iterableexc_types         r   catchrI   `   s    j'*899 	  &0%5%5%7 (!'&-*m3
 )*H((3-.HU   788  	Hh-Z-6   
 ($67* 	 !(H?(B K  r   )rE   zFMapping[type[BaseException] | Iterable[type[BaseException]], _Handler]r9   zAbstractContextManager[None])
__future__r   r*   syscollections.abcr   r   r   
contextlibr   typesr   typingr	   r
   version_info_exceptionsr   _Handlerr   rI   r   r   r   <module>rS      sk    "  
 7 7 -  %g/+C01367HL L^*!V*!!*!r   