
    9[g                    :   d dl mZ d dlZd dlZd dlmZ d dlmZ d dlmZ d dlm	Z	 d dlm
Z
 d dlZd dlZe
rd dlmZ  G d	 d
      ZddZ ej"                  dd      dd       Z ej"                  dd      dd       Z ej"                  dd      dd       Zy)    )annotationsN)TracebackType)Any)Callable)	Generator)TYPE_CHECKING)Selfc                  @    e Zd ZdZddZddZd	dZ	 	 	 	 	 	 	 	 d
dZy)catch_threading_exceptiona  Context manager catching threading.Thread exception using
    threading.excepthook.

    Storing exc_value using a custom hook can create a reference cycle. The
    reference cycle is broken explicitly when the context manager exits.

    Storing thread using a custom hook can resurrect it if it is set to an
    object which is being finalized. Exiting the context manager clears the
    stored object.

    Usage:
        with threading_helper.catch_threading_exception() as cm:
            # code spawning a thread which raises an exception
            ...
            # check the thread exception: use cm.args
            ...
        # cm.args attribute no longer exists at this point
        # (to break a reference cycle)
    c                     d | _         d | _        y N)args	_old_hookselfs    R/var/www/html/bid-api/venv/lib/python3.12/site-packages/_pytest/threadexception.py__init__z"catch_threading_exception.__init__)   s    59	KO    c                    || _         y r   )r   )r   r   s     r   _hookzcatch_threading_exception._hook-   s	    	r   c                Z    t         j                  | _        | j                  t         _        | S r   )	threading
excepthookr   r   r   s    r   	__enter__z#catch_threading_exception.__enter__0   s     "--#zz	r   c                \    | j                   J | j                   t        _        d | _         | `y r   )r   r   r   r   )r   exc_typeexc_valexc_tbs       r   __exit__z"catch_threading_exception.__exit__5   s,     ~~)))#~~	Ir   N)returnNone)r   zthreading.ExceptHookArgsr    r!   )r    r	   )r   ztype[BaseException] | Noner   zBaseException | Noner   zTracebackType | Noner    r!   )__name__
__module____qualname____doc__r   r   r   r    r   r   r   r      sB    (P
	,	 &	 %		
 
	r   r   c               #    K   t               5 } 	 d  | j                  r| j                  j                  dn| j                  j                  j                  }d| d}|dj	                  t        j                  | j                  j                  | j                  j                  | j                  j                              z  }t        j                  t        j                  |             	 d d d        y # | j                  r| j                  j                  dn| j                  j                  j                  }d| d}|dj	                  t        j                  | j                  j                  | j                  j                  | j                  j                              z  }t        j                  t        j                  |             w w xY w# 1 sw Y   y xY ww)Nz	<unknown>zException in thread z

 )r   r   threadnamejoin	tracebackformat_exceptionr   	exc_valueexc_tracebackwarningswarnpytest%PytestUnhandledThreadExceptionWarning)cmthread_namemsgs      r   thread_exception_runtest_hookr7   A   sn    	"	$	Qww#%77>>#9Krww~~?R?R  -[M>rww..(())--  fJJ3OP! 
%	$ ww#%77>>#9Krww~~?R?R  -[M>rww..(())--  fJJ3OP 	 
%	$s4   GGC4CG+	G4CGGGGT)wrappertrylastc               #  4   K   t               E d {    y 7 wr   r7   r&   r   r   pytest_runtest_setupr<   U        ,...   )r8   tryfirstc               #  4   K   t               E d {    y 7 wr   r;   r&   r   r   pytest_runtest_callrA   Z   r=   r>   c               #  4   K   t               E d {    y 7 wr   r;   r&   r   r   pytest_runtest_teardownrC   _   r=   r>   )r    zGenerator[None])
__future__r   r   r,   typesr   typingr   r   r   r   r0   r2   typing_extensionsr	   r   r7   hookimplr<   rA   rC   r&   r   r   <module>rI      s    "           &* *ZQ( t,/ -/ -/ ./ -/ ./r   