
    .PhP(                         d Z ddlZddlZddlmZ 	 ddlmZ  ed          Zn# e$ r  e	            ZY nw xY wg dZ
dd	ZddZ e            Zde_        de_        ej        Zdi efdZedddfdZdS )z
A small set of utilities useful for debugging misbehaving
applications. Currently this focuses on ways to use :mod:`pdb`, the
built-in Python debugger.
    N)Repr   )make_sentinel_UNSET)var_name)pdb_on_signalpdb_on_exception
wrap_tracec                      ddl ddl sj                                         fd}                     |           dS )a  Installs a signal handler for *signalnum*, which defaults to
    ``SIGINT``, or keyboard interrupt/ctrl-c. This signal handler
    launches a :mod:`pdb` breakpoint. Results vary in concurrent
    systems, but this technique can be useful for debugging infinite
    loops, or easily getting into deep call stacks.

    Args:
        signalnum (int): The signal number of the signal to handle
            with pdb. Defaults to :mod:`signal.SIGINT`, see
            :mod:`signal` for more information.
    r   Nc                 z                                                                     t                     d S N)signal	set_tracer   )sigframeold_handlerpdbr   	signalnums     R/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/boltons/debugutils.pypdb_int_handlerz&pdb_on_signal.<locals>.pdb_int_handlerE   s8    i---i         )r   r   SIGINT	getsignal)r   r   r   r   r   s   ` @@@r   r   r   2   s     JJJMMM "M	""9--K! ! ! ! ! ! ! !
 MM)_---
Fr   d   c                 @     ddl ddl}ddl fd}||_        dS )a4  Installs a handler which, instead of exiting, attaches a
    post-mortem pdb console whenever an unhandled exception is
    encountered.

    Args:
        limit (int): the max number of stack frames to display when
            printing the traceback

    A similar effect can be achieved from the command-line using the
    following command::

      python -m pdb your_code.py

    But ``pdb_on_exception`` allows you to do this conditionally and within
    your application. To restore default behavior, just do::

      sys.excepthook = sys.__excepthook__
    r   Nc                 `                         |                               |           d S )N)limit)print_tbpost_mortem)exc_typeexc_valexc_tbr   r   	tracebacks      r   pdb_excepthookz(pdb_on_exception.<locals>.pdb_excepthooke   s4    6///r   )r   sysr#   
excepthook)r   r%   r$   r   r#   s   `  @@r   r	   r	   N   sV    & JJJJJJ              $CN
Fr   2    c                 F   |                      d          t          j                    |                    d          |j        j        |f}| dk    rd}|t          |          fz  }n| dk    rd}|t          |d                   fz  }n| dk    rd	}nd
}|d                    d |D                       fz  }|r7d}|d                    d |                                D                       fz  }|t          ur|dz  }|t          |          fz  }t          ||z             d S )N   
   getz%s %s - %s - %s.%s -> %ssetz%s %s - %s - %s.%s = %sr   delz%s %s - %s - %s.%sz%s %s - %s - %s.%s(%s)z, c                 ,    g | ]}t          |          S r(   
brief_repr).0as     r   
<listcomp>z$trace_print_hook.<locals>.<listcomp>   s    999qZ]]999r   z%s %s - %s - %s.%s(%s, %s)c                 <    g | ]\  }}| d t          |           S )=r0   )r2   kvs      r   r4   z$trace_print_hook.<locals>.<listcomp>   s@     != != !=%)Q %&!7!7
1!7!7 != != !=r   z -> %s)
ljusttimerjust	__class____name__r1   joinitemsr   print)	eventlabelobj	attr_nameargskwargsresultfargstmpls	            r   trace_print_hookrJ   s   sS   [[^^TY[[%++b//]#Y0E~~)*V$$&&	%(*T!W%%''	%#'$))99D999::<< 	@/Ddii != !=-3\\^^!= != != > > @ @EHDj((**E	$,
Fr   c                 V    t          t                    rfd}nJt          t          dd                    rfd}n&t                    r}nt	          dz            pt          t                               t          |t                    r|g}| pd|v | pd|v | pd|v | pd	|v | pd
|v | pd|v f fd	} fd} fd} fd}	i }
t                     D ]s}	 t           |          }n# t          $ r Y  w xY wt          |          r|dv r8|r |||          sG|dk    r|}n|dk    r|}n|dk    r|	}n |||          }||
|<   t j	        j
        }||                                k    rd|z   }nd|z   }t           d          r	 j	        f}n j	        t          f}t          |||
          }|j        D ])}	 |                    |          c S # t          $ r Y &w xY wt	          d j	        d           )a  Monitor an object for interactions. Whenever code calls a method,
    gets an attribute, or sets an attribute, an event is called. By
    default the trace output is printed, but a custom tracing *hook*
    can be passed.

    Args:
       obj (object): New- or old-style object to be traced. Built-in
           objects like lists and dicts also supported.
       hook (callable): A function called once for every event. See
           below for details.
       which (str): One or more attribute names to trace, or a
           function accepting attribute name and value, and returning
           True/False.
       events (str): One or more kinds of events to call *hook*
           on. Expected values are ``['get', 'set', 'del', 'call',
           'raise', 'return']``. Defaults to all events.
       label (str): A name to associate with the traced object
           Defaults to hexadecimal memory address, similar to repr.

    The object returned is not the same object as the one passed
    in. It will not pass identity checks. However, it will pass
    :func:`isinstance` checks, as it is a new instance of a new
    subtype of the object passed.

    c                     | k    S r   r(   rD   attr_valwhichs     r   <lambda>zwrap_trace.<locals>.<lambda>   s    e1C r   __contains__Nc                     | v S r   r(   rM   s     r   rP   zwrap_trace.<locals>.<lambda>   s    e1C r   z*expected attr name(s) or callable, not: %rr,   r-   r.   callraisereturnc                      	fd}j         |_         j        |_        	 j        |_        n# t          $ r Y nw xY w	 j        r|j                            j                   n# t          $ r Y nw xY w|S )Nc                      | dd          } r 	d
| |           r>	  | i |}n<# t           $ r'  	d
| |t          j                              s Y nw xY w | i |}r 	d
| ||           |S )Nr   rS   )rA   rB   rC   rD   rE   rF   rT   )rA   rB   rC   rD   rE   rF   rG   rU   )	Exceptionr%   exc_info)r3   kwret_labelrD   do_calldo_raise	do_returnfunchookrC   s      r   wrappedz0wrap_trace.<locals>.wrap_method.<locals>.wrapped   s   !""A =6S(q= = = = 	%$.R..CC    4gV*3!B'*|~~7 7 7    dAnnn I86s(qCI I I IJs   + .AA)r=   __doc__
__module__rX   __dict__update)
rD   r`   _hookr\   rb   r]   r^   r_   ra   rC   s
   `` ` r   wrap_methodzwrap_trace.<locals>.wrap_method   s    	 	 	 	 	 	 	 	 	 	 	 	(  =,	!%G 	 	 	D		} 7 ''666 	 	 	D	s!   7 
AA&A/ /
A<;A<c           	          t                                        |          }t          |          r#t                                        | |          }r d|di |           |S )Nr,   r(   )rG   )type__getattribute__callable)selfrD   r[   do_getra   rB   rC   s      r   rk   z$wrap_trace.<locals>.__getattribute__   st    3ii((i88C== 	>s)),,T9==C 	CDsIr2cBBBB
r   c                 v    t                                        ||           r d||fi            d S )Nr-   )rj   __setattr__)rm   rD   valuedo_setra   rB   rC   s      r   rp   zwrap_trace.<locals>.__setattr__   sJ    S		c9e444 	=DsIx<<<r   c                 r    t                                        |           r d|di            d S )Nr.   r(   )rj   __delattr__)rm   rD   do_delra   rB   rC   s     r   rt   zwrap_trace.<locals>.__delattr__   sF    S		c9--- 	7DsIr2666r   )__new__rk   rp   rt   traced_Traced__mro__zunable to wrap_trace z
 instance )
isinstancestrrl   getattr	TypeErrorhexiddirrX   r<   r=   lowerhasattrobjectrj   ry   rv   )rC   ra   rO   eventsrB   
which_funcrh   rk   rp   rt   attrsrD   rN   wrapped_methodcls_name	type_namebases
trace_typeclsr]   ru   rn   r^   r_   rr   s   ``` `              @@@@@@r   r
   r
      s   B % NCCCC

	'%66	7	7 NCCCC

	(5//

DuLMMM!SC\\E&# Z*5F?FZ*5F?FZ*5F?Fj,Ff,Gz.W.H
0h&0I+/                    D                      EXX * *		sI..HH 	 	 	H	 !! 	Y,%>%> 	

9h ? ? 	***-NN-''(NN-''(NN([H==N)i}%H8>>####(		x'	sI (  'i..J!  	;;z***** 	 	 	D	
)}}}cc+ , , ,s$   D
D&%D&*H
HHr   )r   )rc   r%   r:   reprlibr   	typeutilsr   r   ImportErrorr   __all__r   r	   	_repr_obj	maxstringmaxotherreprr1   rJ   r
   r(   r   r   <module>r      s0  >  


       ((((((]H---FF   VXXFFF >
=
=   8   < DFF		 	 ^

 R   4 *$dU, U, U, U, U, U,s   % 77