
    ?g                    :   S SK Jr  S SKrS SKrS SKJr  S SKJr  S SKJr  S SKJ	r	  S SKJ
r
  S SKrS SKr\
(       a  S SKJr   " S	 S
5      rSS jr\R"                  " SSS9SS j5       r\R"                  " SSS9SS j5       r\R"                  " SSS9SS j5       rg)    )annotationsN)TracebackType)Any)Callable)	Generator)TYPE_CHECKING)Selfc                  P    \ rS rSrSrS	S jrS
S jrSS jr        SS jrSr	g)catch_threading_exception   a  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                     S U l         S U l        g N)args	_old_hookselfs    9/usr/lib/python3/dist-packages/_pytest/threadexception.py__init__"catch_threading_exception.__init__)   s    59	KO    c                    Xl         g r   )r   )r   r   s     r   _hookcatch_threading_exception._hook-   s    	r   c                Z    [         R                  U l        U R                  [         l        U $ r   )	threading
excepthookr   r   r   s    r   	__enter__#catch_threading_exception.__enter__0   s     "--#zz	r   c                ^    U R                   c   eU R                   [        l        S U l         U ?g r   )r   r   r   r   )r   exc_typeexc_valexc_tbs       r   __exit__"catch_threading_exception.__exit__5   s,     ~~)))#~~	Ir   )r   r   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____firstlineno____doc__r   r   r   r#   __static_attributes__ r   r   r   r      sB    (P
	,	 &	 %		
 
	r   r   c               #    #    [        5        n  S v   U R                  (       a  U R                  R                  c  SOU R                  R                  R                  nSU S3nUSR	                  [
        R                  " U R                  R                  U R                  R                  U R                  R                  5      5      -  n[        R                  " [        R                  " U5      5        S S S 5        g ! U R                  (       a  U R                  R                  c  SOU R                  R                  R                  nSU S3nUSR	                  [
        R                  " U R                  R                  U R                  R                  U R                  R                  5      5      -  n[        R                  " [        R                  " U5      5        f f = f! , (       d  f       g = f7f)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_hookr>   A   sm    	"	$	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   G3G"C<C G"3	G3<C#GG""
G0,G3T)wrappertrylastc               #  4   #    [        5        S h  vN   g  N7fr   r>   r-   r   r   pytest_runtest_setuprC   U        ,...   )r?   tryfirstc               #  4   #    [        5        S h  vN   g  N7fr   rB   r-   r   r   pytest_runtest_callrH   Z   rD   rE   c               #  4   #    [        5        S h  vN   g  N7fr   rB   r-   r   r   pytest_runtest_teardownrJ   _   rD   rE   )r%   zGenerator[None])
__future__r   r   r3   typesr   typingr   r   r   r   r7   r9   typing_extensionsr	   r   r>   hookimplrC   rH   rJ   r-   r   r   <module>rP      s    "           &* *ZQ( t,/ -/ -/ ./ -/ ./r   