o
    Zh                     @   s  d dl Z d dlZd dlmZmZ d dlmZ d dlmZ erFd 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mZ edZe jd  dkZe jd  dkoZe jd dkZe jd  dkohe jd dkZe jd  dkove jd dkZe jd  dkoe jd dkZerd dlZeZeefZeeefZeefZdd Z e!e"fZ#dd Z$dd Z%dd Z&dd Z'e(d dd Z)n9d dlm*Z* d dl+m,Z eZefZeefZefZd d Z e-e!e"fZ#d!d Z$d"d Z%d#d Z&d$d Z'd+d%d&Z.ej)Z)d'd( Z/d)d* Z0dS ),    N)datetime	timedeltawraps)TYPE_CHECKING)Optional)Tuple)Any)Type)TypeVar)CallableT            
      c                 C      |   S N)	iteritemsx r   I/var/www/html/lang_env/lib/python3.10/site-packages/sentry_sdk/_compat.py<lambda>!       r   c                   C   s   t  S r   )r   utcnowr   r   r   r   datetime_utcnow$   s   r   c                 C   s
   t | S r   )r   utcfromtimestamp	timestampr   r   r   utc_from_timestamp(   s   
r"   c                 C   s2   | j d d d | j }|d t| jd  }|S )N   <   i  )dayssecondsfloatmicroseconds)deltar&   millisecondsr   r   r   duration_in_milliseconds,   s   r+   c                 C   s   | j | _dd | _ | S )Nc                 S   s   t | dS )Nzutf-8)unicodeencoder   r   r   r   r   5   s    z implements_str.<locals>.<lambda>)__str____unicode__)clsr   r   r   implements_str2   s   
r1   z5def reraise(tp, value, tb=None):
 raise tp, value, tbc                    s(   t |  t| G  fddd}|S )z
        Decorator which creates a contextmanager that can also be used as a
        decorator, similar to how the built-in contextlib.contextmanager
        function works in Python 3.2+.
        c                       s0   e Zd Z fddZdd Zdd Zdd Zd	S )
z/contextmanager.<locals>.DecoratorContextManagerc                    s    |i || _ d S r   the_contextmanagerselfargskwargsZcontextmanager_funcr   r   __init__F   s   z8contextmanager.<locals>.DecoratorContextManager.__init__c                 S   s   | j   d S r   )r3   	__enter__)r5   r   r   r   r:   J      z9contextmanager.<locals>.DecoratorContextManager.__enter__c                 _   s   | j j|i | d S r   )r3   __exit__r4   r   r   r   r<   N   s   z8contextmanager.<locals>.DecoratorContextManager.__exit__c                    s   t   fdd}|S )Nc                     s:   j   | i |}W d    |S 1 sw   Y  |S r   r2   )r6   r7   
return_valdecorated_funcr5   r   r   when_calledT   s   
zMcontextmanager.<locals>.DecoratorContextManager.__call__.<locals>.when_calledr   )r5   r?   r@   r   r>   r   __call__R   s   z8contextmanager.<locals>.DecoratorContextManager.__call__N)__name__
__module____qualname__r9   r:   r<   rA   r   r8   r   r   DecoratorContextManagerD   s
    rE   )
contextlibcontextmanagerr   )funcrE   r   r8   r   rG   ;   s   
rG   )timezonec                 C   r   r   )itemsr   r   r   r   r   g   r   c                   C   s   t tjS r   )r   nowrI   utcr   r   r   r   r   j      c                 C   s   t | tjS r   )r   fromtimestamprI   rL   r    r   r   r   r"   n   r;   c                 C   s   | t dd S )Nr   )r*   )r   )r)   r   r   r   r+   r   r;   c                 C   s   | S r   r   r   r   r   r   r1   v   s   c                 C   s$   |d usJ |j |ur|||r   )__traceback__with_traceback)tpvaluetbr   r   r   reraisez   s   

rT   c                    s&   G  fdddt }t |ddi S )Nc                       s   e Zd Z fddZdS )z!with_metaclass.<locals>.MetaClassc                    s   | |S r   r   )metaclsname
this_basesdbasesmetar   r   __new__   rM   z)with_metaclass.<locals>.MetaClass.__new__N)rB   rC   rD   r\   r   rY   r   r   	MetaClass   s    r]   temporary_classr   )typer\   )r[   rZ   r]   r   rY   r   with_metaclass   s   r`   c                     s   zddl m W n
 ty   Y dS w ddlm   fdd} dv p'| d}| d	}| d
p3| d}|rF|sFddlm} |td dS |sZ|rL|sZddlm} |td dS dS )Nr   )optT)FALSE_VALUESc                    sX    | d}t|tr|S t|tr"z| }W n	 ty!   Y nw |o+t|  vS )NF)get
isinstanceboolbytesdecode	Exceptionstrlower)optionrR   rb   ra   r   r   enabled   s   

z+check_uwsgi_thread_support.<locals>.enabledthreadszenable-threadszpy-call-uwsgi-fork-hooksz	lazy-appsZlazy)warnzIMPORTANT: We detected the use of uWSGI without thread support. This might lead to unexpected issues. Please run uWSGI with "--enable-threads" for full support.FzIMPORTANT: We detected the use of uWSGI in preforking mode without thread support. This might lead to crashing workers. Please run uWSGI with both "--enable-threads" and "--py-call-uwsgi-fork-hooks" for full support.)Zuwsgira   ImportErrorZsentry_sdk.constsrb   warningsro   Warning)rm   Zthreads_enabledZfork_hooks_onZ	lazy_modero   r   rl   r   check_uwsgi_thread_support   s6   	
rs   r   )1sysrF   r   r   	functoolsr   Zsentry_sdk._typesr   typingr   r   r	   r
   r   r   r   version_infoPY2ZPY33ZPY37PY310ZPY311urlparser,   	text_typeri   string_typesintlongr'   Znumber_typesZ	int_typesr   	bytearray
memoryviewZbinary_sequence_typesr   r"   r+   r1   execrG   rI   urllib.parseparserf   rT   r`   rs   r   r   r   r   <module>   s`    

%


