+
    Ni                     @   ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
t
^ RIt^ RIHt ^ RIHtHt ^ RIHt ^ RIHtHtHt ^ RIHt ^ RIHtHtHtHtHt  ^ RIHt ^ R	I!H"t" ^ RI#t#^ R
I$H%t% ^ RI&H't'H(t(H)t) ^ RI*H+t+H,t,H-t-H.t. ]"'       dQ   ^ RI/H0t0H1t1 ^ RI!H2t2H3t3H4t4H5t5H6t6H7t7H8t8H9t9H:t:H;t;H<t<H=t=H>t>H?t?H@t@HAtA ^ RIBHCtC ^ RI&HDtDHEtEHFtFHGtGHHtH ]:! R4      tI]>! R4      tJ]! R^^4      tK]P                  ! R4      tMRsN]P                  ! R4      tP]Q! R4      tR]Q! R4      tSRtT RR/R R lltUR R ltVR R ltWR R  ltXR! R" ltY ! R# R$4      tZ]Z! 4       t[R% R& lt\R' R( lt]R) R* lt^R+ R, lt_]Q! R4      t`R- R. ltaRR/ R0 lltb ! R1 R2]c4      td ! R3 R44      te ! R5 R64      tfR7 R8 ltgR9 R: lthR; R< ltiR= R> ltjRR? R@ lltkRRA RB lltlRC RD ltmRE RF ltnRG RH ltoRRI RJ lltpRRK RL lltqRM RN ltrRO RP ltsRRQ RR lltt]u! ]vRS4      tw]w'       d   RT RU ltxMRV RW ltxRRX RY lltyRRZ R[ lltzR\ R] lt{R^ R_ lt|R` Ra lt}RRb Rc llt~RRd Re lltRf Rg ltRh Ri ltRRj Rk lltRl Rm ltRn Ro ltRp Rq ltRr Rs ltRt Ru ltRRv Rw lltRx Ry ltRz R{ ltR| R} ltR~ R lt]! 4       w  ttRtR R ltR R lt]! R4      t ! R R]v4      t ! R R]
EP(                  4      tR R ltR R lt]! R. RO4      tRR R llt]! R. RO4      tRR R lltR R ltRR R lltR R ltR R ltR R ltR R ltR R ltR R ltRR R lltR R lt]"'       d   ]AR R l4       t]AR R l4       t]3R R llt]%'       d   R R ltMR R ltR R lt ^ RIHt ^ RIHt R R ltRR R lltR R lt]"'       d	   ]>! R4      tR R ltR R ltR R ltR R ltR R ltR R ltR#   ]  d    Rt ELi ; i  ]  d    R R ltR R lt Loi ; i)    N)
namedtuple)datetimetimezone)Decimal)partialpartialmethodwraps)Real)parse_qsunquote	urlencodeurlsplit
urlunsplit)BaseExceptionGroup)TYPE_CHECKING)PY37)SENSITIVE_DATA_SUBSTITUTE	AnnotatedAnnotatedValue)DEFAULT_ADD_FULL_STACKDEFAULT_MAX_STACK_FRAMESDEFAULT_MAX_VALUE_LENGTHEndpointType)	FrameTypeTracebackType)AnyCallableContextManagerDictIteratorListNoReturnOptional	ParamSpecSetTupleTypeTypeVarUnioncastoverload)Hub)EventExcInfoHintLogMetricPRi  zsentry_sdk.errorsz^[a-zA-Z0-9/+=]*$i  strictFc                $    V ^8  d   QhRRRRRR/# )   valuer   r4   zOptional[bool]returnzbool | None )formats   "7/tmp/pip-target-e6j6ikcs/lib/python/sentry_sdk/utils.py__annotate__r<   Z   s"     + +u +)9 +m +    c                   V e   \        V 4      P                  4       MRpV\        9   d   R# V\        9   d   R# V'       d   R# \	        V 4      # )zCasts an ENV variable value to boolean using the constants defined above.
In strict mode, it may return None if the value doesn't match any of the predefined values.
NFT)strlowerFALSY_ENV_VALUESTRUTHY_ENV_VALUESbool)r7   r4   
normalizeds   &$ r;   env_to_boolrE   Z   sF     (-'8U!!#dJ%%&&4*tE{*r=   c                (    V ^8  d   QhRRR\         /# r6   datar   r8   )bytes)r:   s   "r;   r<   r<   i   s     T TU Tu Tr=   c                R    \         P                  ! V RRR7      P                  R4      # )zCSerialize data into a compact JSON representation encoded as UTF-8.F)	allow_nan
separatorsutf-8),:)jsondumpsencode)rH   s   &r;   
json_dumpsrS   i   s     ::de
CJJ7SSr=   c                    V ^8  d   QhRR/# r6   r8   Optional[str]r9   )r:   s   "r;   r<   r<   n   s      / r=   c            
      ^    \        \        P                  P                  R 4      ;_uu_ 4       p Rp\        P
                  R8X  g   \        P
                  R8X  d=   \        P                  ! 4       pV;P                  \        P                  ,          un        \        P                  ! . ROV\        P                  V V R7      P                  4       ^ ,          P                  4       P                  R4      pRRR4       V#   + '       g   i     X# ; i  \        \         \"        3 d     R# i ; i)zw+Nwin32cygwin)startupinfostdoutstderrstdinrM   )gitz	rev-parseHEAD)openospathdevnullsysplatform
subprocessSTARTUPINFOdwFlagsSTARTF_USESHOWWINDOWPopenPIPEcommunicatestripdecodeOSErrorIOErrorFileNotFoundError)nullrZ   revisions      r;   get_git_revisionrt   n   s    "''//4((DK||w&#,,(*B(446##z'F'FF#   0 +%?? q"   ), O- )(, O W/0 s/   ,D CC>4D >D		D D D,+D,c                    V ^8  d   QhRR/# rU   r9   )r:   s   "r;   r<   r<      s      _ r=   c                     \         P                  P                  R4      p V '       d   V # \        4       p V '       d   V # R F.  p\         P                  P                  V4      p V '       g   K,  V u # 	  R# )zTry to guess a default release.SENTRY_RELEASEN)HEROKU_SLUG_COMMITSOURCE_VERSION!CODEBUILD_RESOLVED_SOURCE_VERSIONCIRCLE_SHA1GAE_DEPLOYMENT_ID
K_REVISION)ra   environgetrt   )releasevars     r;   get_default_releaser      s\    jjnn-.G G **..%7N r=   c                (    V ^8  d   QhRRR\         /# )r6   installed_integrationsz	List[str]r8   r?   )r:   s   "r;   r<   r<      s            r=   c                R    . ROpV F  pW 9   g   K  RP                  V4      u # 	  R# )zAReturn the SDK name including the name of the used web framework.zsentry.python.{}zsentry.python)djangoflaskfastapibottlefalconquartsanic	starlettelitestarstarlitechalice
serverlesspyramidtornadoaiohttp
aws_lambdagcpbeamasgiwsgi)r:   )r   framework_integrationsintegrations   &  r;   get_sdk_namer      s2    
. .0%,,[99 . r=   c                   H   a  ] tR t^t o RtV 3R lR ltV 3R lR ltRtV tR# )CaptureInternalExceptionc                   < V ^8  d   QhRR/# r6   r8   zContextManager[Any]r9   )r:   __classdict__s   "r;   r<   %CaptureInternalException.__annotate__   s      0 r=   c                    V # Nr9   selfs   &r;   	__enter__"CaptureInternalException.__enter__   s    r=   c                ,   < V ^8  d   QhRRRRRRRS[ /# )r6   tyOptional[Type[BaseException]]r7   Optional[BaseException]tbOptional[TracebackType]r8   rC   )r:   r   s   "r;   r<   r      s3     	 	+	 )	 &		
 
	r=   c                0    Ve   Ve   \        WV34       R# )NT)capture_internal_exception)r   r   r7   r   s   &&&&r;   __exit__!CaptureInternalException.__exit__   s     >e/&27r=   r9   N)	__name__
__module____qualname____firstlineno__	__slots__r   r   __static_attributes____classdictcell__r   s   @r;   r   r      s     I 	 	r=   r   c                    V ^8  d   QhRR/# r   r9   )r:   s   "r;   r<   r<      s     ' '%: 'r=   c                      \         # r   )_CAPTURE_INTERNAL_EXCEPTIONr9   r=   r;   capture_internal_exceptionsr      s    &&r=   c                     V ^8  d   QhRRRR/# )r6   exc_infor.   r8   Nr9   )r:   s   "r;   r<   r<      s     H H Ht Hr=   c                    \         P                  ! 4       P                  4       '       d   \        P	                  RV R7       R# R# )z
Capture an exception that is likely caused by a bug in the SDK
itself.

These exceptions do not end up in Sentry and are just logged instead.
zInternal error in sentry_sdkr   N)
sentry_sdk
get_client	is_activeloggererrorr   s   &r;   r   r      s2     ((**3hG +r=   c                (    V ^8  d   QhRRR\         /# r6   r7   r   r8   float)r:   s   "r;   r<   r<      s     + +
 +u +r=   c                 8    V \         ,
          P                  4       # r   )epochtotal_secondsr7   s   &r;   to_timestampr      s    EM((**r=   c                (    V ^8  d   QhRRR\         /# r   r   )r:   s   "r;   r<   r<      s     	5 	5J 	53 	5r=   c                b    V P                  \        P                  4      pVP                  R4      # )zFormats a timestamp in RFC 3339 format.

Any datetime objects with a non-UTC timezone are converted to UTC, so that all timestamps are formatted in UTC.
z%Y-%m-%dT%H:%M:%S.%fZ)
astimezoner   utcstrftime)r7   utctimes   & r;   format_timestampr      s,    
 x||,G 344r=   c                (    V ^8  d   QhR\         RR/# )r6   r7   r8   r   r   )r:   s   "r;   r<   r<      s     + +3 +: +r=   c                     \         P                  ! V 4      pVP                  \        P                  4      #   \        \        3 d    R T 9   d   RMRpT P	                  R4      '       d   T RR R,           p T R,          \
        9   d   TR,          pT RR	 T R
R ,           p MT R,          \
        9   d
   TR,          p\         P                  ! Y4      p Li ; i).z%Y-%m-%dT%H:%M:%S.%fz%Y-%m-%dT%H:%M:%SZNz+0000z%zi)
r   fromisoformatAttributeError
ValueErrorendswithISO_TZ_SEPARATORSstrptimer   r   r   )r7   resulttimestamp_formats   &  r;   datetime_from_isoformatr      s    <''.  X\\** J' < '*Ul"8K 	 >>##2J(E9))$#2Jrs+E2Y++$""5;<s   7 2C*A(CCc                     V ^8  d   QhRRRR/# )r6   r   zOptional[ExcInfo]r8   zDict[str, Optional[ExcInfo]]r9   )r:   s   "r;   r<   r<     s     
" 
"!
"#
"r=   c                n    V f   \         P                  ! 4       p M\        V 4      p V ^ ,          f   Rp RV /# )z+Creates a hint with the exc info filled in.Nr   )rd   r   exc_info_from_errorr   s   &r;   event_hint_with_exc_infor     s9     <<>&x0{!!r=   c                       ] tR tRtRtRtR# )BadDsni  zRaised on invalid DSNs.r9   Nr   r   r   r   __doc__r   r9   r=   r;   r   r     s    !r=   r   c                      a  ] tR tRt o Rt]P                  ! R4      tRV 3R lR llt]	V 3R lR l4       t
RV 3R	 lR
 lltV 3R lR ltRtV tR# )Dsni!  zRepresents a DSN.z	^o(\d+)\.Nc                &   < V ^8  d   QhRRRRRR/# )r6   r7   zUnion[Dsn, str]org_idrV   r8   Nr9   )r:   r   s   "r;   r<   Dsn.__annotate__&  s%     )) ))&))0?))	))r=   c                ^   \        V\        4      '       d   \        VP                  4      V n        R # \	        \        V4      4      pVP                  R
9  d   \        RVP                  ,          4      hVP                  V n        VP                  f   \        R4      hVP                  V n	        Ve   W n
        MI\        P                  P                  V P                  4      pV'       d   VP                  ^4      MR V n
        VP                  f*   V P                  R8H  ;'       d    R;'       g    ^PV n        MVP                  V n        VP                  '       g   \        R4      hVP                  V n        VP"                  V n        VP&                  P)                  R^4      p \        \+        VP-                  4       4      4      V n        RP5                  T4      R,           T n        R #   \0        \2        3 d/    \        RTP&                  ;'       g    RR	,          ,          4      hi ; i)NhttpszUnsupported scheme %rzMissing hostname  zMissing public key/zInvalid project in DSN (%r) :   NN)httpr   )
isinstancer   dict__dict__r   r?   schemer   hostnamehostr   ORG_ID_REGEXmatchgroupportusername
public_keypassword
secret_keyrb   rsplitintpop
project_idr   	TypeErrorjoin)r   r7   r   partsorg_id_matchrb   s   &&&   r;   __init__Dsn.__init__&  s    eS!! 0DMU$<<0005<<?@@ll>>!+,,NN	+1K++11$))<L3?,,,Q/TDK::![[G3;;AArDI

DI~~~-......zz  a(	Q!#dhhj/2DO HHTNS(	 I& 	Q6%**:J:JB9OOPP	Qs   ''G- -)H,H,c                    < V ^8  d   QhRS[ /# r6   r8   r   )r:   r   s   "r;   r<   r   R  s       r=   c                ~    V P                   pV P                  V P                  3R9  d   V: RV P                  : 2pV# )zThe netloc part of a DSN.rO   ))r   P   )r   r   )r  r  r  r   rvs   & r;   netloc
Dsn.netlocQ  s6     YYKK#+II		*B	r=   c                "   < V ^8  d   QhRRRR/# )r6   clientOptional[Any]r8   Authr9   )r:   r   s   "r;   r<   r   Y  s     

 

o 

 

r=   c           
         \        V P                  V P                  V P                  V P                  V P
                  V P                  VR7      # )z*Returns the auth info object for this dsn.)r  r  rb   r  r
  r  r   )r"  r  r  rb   r  r
  r  )r   r   s   &&r;   to_authDsn.to_authY  s<    ;;
 	
r=   c                    < V ^8  d   QhRS[ /# r  r   )r:   r   s   "r;   r<   r   e  s     
 
 
r=   c                    V P                   : R V P                  : V P                  ;'       d    RV P                  ,           ;'       g    R: RV P                  : V P                  : V P
                  : 2# )://@r   )r  r
  r  r  rb   r  r   s   &r;   __str__Dsn.__str__e  sR    KKOOOO55doo 5;;;KKIIOO
 	
r=   )	r  r  r   rb   r  r  r
  r  r  r   )r   r   r   r   r   recompiler  r  propertyr  r$  r*  r   r   r   s   @r;   r   r   !  sI     ::l+L)) ))V  

 


 
r=   r   c                   x   a  ] tR tRt o RtRV 3R lR llt]P                  3V 3R lR lltV 3R lR	 lt	R
t
V tR# )r"  ip  z,Helper object that represents the auth info.Nc                J   < V ^8  d   QhRS[ RS[ RS[ RS[ RRRS[RR	R
S[ RR/	# )r6   r  r  r  r
  r  rV   versionr   r!  rb   r8   Nr?   r  )r:   r   s   "r;   r<   Auth.__annotate__s  se        	
  $     
r=   c	                f    Wn         W n        Wn        W0n        W@n        WPn        W`n        Wpn        R # r   )r  r  rb   r  r
  r  r1  r   )	r   r  r  r  r
  r  r1  r   rb   s	   &&&&&&&&&r;   r  Auth.__init__s  s,     		$$$r=   c                $   < V ^8  d   QhRRRS[ /# )r6   typer   r8   r   )r:   r   s   "r;   r<   r3    s     
 

 

r=   c           	         V P                   : RV P                  : V P                  : RV P                  : RVP                  : R2	# )z'Returns the API url for storing events.r(  zapi/r   )r  r  rb   r  r7   )r   r7  s   &&r;   get_api_urlAuth.get_api_url  s1     KKIIIIOOJJ
 	
r=   c                    < V ^8  d   QhRS[ /# r  r   )r:   r   s   "r;   r<   r3    s     R R3 Rr=   c                $   RV P                   3RV P                  3.pV P                  e   VP                  RV P                  34       V P                  e   VP                  RV P                  34       RRP                  R V 4       4      ,           # )z!Returns the auth header a string.
sentry_keysentry_versionsentry_clientsentry_secretzSentry z, c              3   8   "   T F  w  rV: R V: 2x  K  	  R# 5i)=Nr9   ).0keyr7   s   &  r;   	<genexpr>!Auth.to_header.<locals>.<genexpr>  s     $Qb
U%;bs   )r
  r1  r   appendr  r  r  s   & r;   	to_headerAuth.to_header  sw    T__-0@$,,/OP;;"II45??&II89499$Qb$QQQQr=   )r   r  rb   r  r
  r  r  r1  )N   Nr   )r   r   r   r   r   r  r   ENVELOPEr9  rH  r   r   r   s   @r;   r"  r"  p  s3     6 ,  ,44
 
R Rr=   r"  c                     V ^8  d   QhRRRR/# r6   clsOptional[type]r8   rV   r9   )r:   s   "r;   r<   r<     s     P P' PO Pr=   c                 F    \        V R R4      ;'       g    \        V RR4      # )r   Nr   getattr)rN  s   &r;   get_type_namerS    s"    3-OOj$1OOr=   c                     V ^8  d   QhRRRR/# rM  r9   )r:   s   "r;   r<   r<     s      ) o r=   c                 2    \        V R R4      pVR9  d   V# R# )r   N)Nbuiltins__builtins__rQ  )rN  mods   & r;   get_type_modulerY    s!    
#|T
*C
44
r=   c                (    V ^8  d   QhRRR\         /# )r6   framer   r8   r   )r:   s   "r;   r<   r<     s      [ T r=   c                      V P                   R ,          pVP                  R4      '       d   R#  R F   p V P                  V,          '       d    R# K"  	  R#   \        \        3 d     L;i ; i  \
         d     KK  i ; i)r   zsentry_sdk.TF)__traceback_hide____tracebackhide__)	f_globals
startswithr   KeyErrorf_locals	Exception)r[  rX  	flag_names   &  r;   should_hide_framere    s    ooj)>>-(( )
 ?		~~i(( ) ?  H%   		s"   )A A.A+*A+.A=<A=c                     V ^8  d   QhRRRR/# )r6   r   r   r8   zIterator[TracebackType]r9   )r:   s   "r;   r<   r<     s      - 2K r=   c              #   t   "   T pVe.   \        VP                  4      '       g   Vx  VP                  pK1  R # 5ir   )re  tb_frametb_next)r   tb_s   & r;   iter_stacksrk    s1     %'C
/ ..Ikk s   68c                @    V ^8  d   QhR\         R\        RRRRRRR	R
/# )r6   filenamelineno
max_lengthOptional[int]loaderr!  modulerV   r8   KTuple[List[Annotated[str]], Optional[Annotated[str]], List[Annotated[str]]]r2  )r:   s   "r;   r<   r<     sE     * ***  * 	*
 * S*r=   c                    ^pRpVe9   \        VR4      '       d'    VP                  V4      pVe   VP	                  4       pVf    \
        P                  ! V 4      pV'       g   . R. 3# \        ^ W,
          4      p\        V^,           V,           \        V4      4      p	 WhV  U
u. uF  p
\        V
P                  R4      VR7      NK!  	  pp
\        Wa,          P                  R4      VR7      pWa^,           V	  U
u. uF  p
\        V
P                  R4      VR7      NK!  	  pp
WV3#   \        \        3 d    Rp ELi ; i  \        \        3 d	    . R. 3u # i ; iu up
i u up
i   \         d	    . R. 3u # i ; i)   N
get_sourcez
)ro  )hasattrrv  ImportErrorrp   
splitlines	linecachegetlinesro   maxminlenstrip_stringrm   
IndexError)rm  rn  ro  rq  rr  context_linessource
source_strlower_boundupper_boundlinepre_contextcontext_linepost_contexts   &&&&&         r;   get_lines_from_filer    s    MFgfl;;	*0*;*;F*CJ !**,F~	 ''1F 4|a/0Kfqj=0#f+>K 62
2 F+
C2 	 
 $FN$8$8$@ZX 
k:
: F+
C: 	 
 ,667 W% 	J	 ! 	 tR<	 



  4|sS   D& E  E& %%E
1E& ;%E! E& &D=<D= EE
E& &E98E9c                (    V ^8  d   QhRRRRRRRR/# )r6   r[  r   	tb_linenorp  max_value_lengthr8   rs  r9   )r:   s   "r;   r<   r<     s1       & S	r=   c                 H    V P                   P                  p V P                  R,          p T P                  R,          pTe    T'       d   T^,
          p\	        Y6Y%TR7      # . R . 3#   \         d    R p L_i ; i  \         d	    . R . 3u # i ; i  \         d    R p L`i ; i)Nr   
__loader__)rq  rr  )f_codeco_filenamerc  r_  r  )r[  r  r  abs_pathrr  rq  rn  s   &&&    r;   get_source_contextr    s    
$)LL$<$<,. Q".f
 	
 tR<#    4|  s3   A( A; B (A87A8;BBB! B!c                (    V ^8  d   QhRRR\         /# r6   r7   r   r8   r   )r:   s   "r;   r<   r<     s        E  c  r=   c                 R     \        V 4      #   \         d    \        T 4      u # i ; ir   )r?   rc  	safe_reprr   s   &r;   safe_strr    s+     5z   s   
 &&c                (    V ^8  d   QhRRR\         /# r  r   )r:   s   "r;   r<   r<     s      U s r=   c                 >     \        V 4      #   \         d     R # i ; i)z<broken repr>)reprrc  r   s   &r;   r  r    s#    E{ s   
 c                $    V ^8  d   QhRRRRRR/# )r6   rr  rV   r  r8   r9   )r:   s   "r;   r<   r<     s$      '6r=   c                    V'       d	   V '       g   V#  VP                  R 4      '       d   VRR pV P                  R^4      ^ ,          pW 8X  d    \        P                  P	                  V4      # \
        P                  V,          P                  pV'       g   V# VP                  VP                  \        P                  ^4      ^ ,          ^4      R,          P                  \        P                  4      #   \         d    Tu # i ; i)z.pycNr   r   )r   splitra   rb   basenamerd   modules__file__r  seplstriprc  )rr  r  base_modulebase_module_paths   &&  r;   filename_for_moduler    s     6V$$}Hll3*1- 77##H--;;{3<<O~~.55bffa@CQGKRRFF
 	
  s*   C4 AC4 .(C4 C4 AC4 4DDc                D    V ^8  d   QhRRRRR\         R\         RRRR	R
R/# )r6   r[  r   r  rp  include_local_variablesinclude_source_contextr  custom_reprz&Optional[Callable[..., Optional[str]]]r8   Dict[str, Any]r   )r:   s   "r;   r<   r<   2  sN     0 000 "0 !	0
 &0 :0 0r=   c           
      l   \        V R R4      pV'       g   RpRpM,V P                  P                  pV P                  P                  p V P                  R,          p	Vf   V P                  p V'       d    \        P                  P                  V4      MRp
R\        W4      ;'       g    RRT
RT;'       g    RRV	RV/pV'       d   \        WV4      w  VR	&   VR
&   VR&   V'       d(   ^ RIHp V! \        V P                  4      RVR7      VR&   V#   \
         d    Rp	 Li ; i  \
         d    Rp
 Li ; i)r  Nr   rm  r  functionz	<unknown>rr  rn  r  r  r  )	serializeT)is_varsr  vars)rR  r  r  co_namer_  rc  f_linenora   rb   abspathr  r  sentry_sdk.serializerr  r   rb  )r[  r  r  r  r  r  r  r  r  rr  os_abs_pathr  r  s   &&&&&&       r;   serialize_framer  2  s8    UHd+F<<++<<'', NN	3;bggooh/
 	'9AATKH++&)B DV.E
A=2n-r./A 3 $K
6
 I?    s*   D ,D# 4!D# D D #D32D3c                8    V ^8  d   QhR\         R\         RRRR/# )r6   r  r  r  rp  r8   r  r   )r:   s   "r;   r<   r<   e  s0      !  & 	r=   c           	          R p. p\         P                  ! 4       pVe>   \        V4      '       g   VP                  \	        VV VVR7      4       VP
                  pKA  VP                  4        RV/# )T)r  r  r  frames)rd   	_getframere  rG  r  f_backreverse)r  r  r  r^  r  fs   &&&   r;   current_stacktracer  e  sj    
 F"}}A
- ##MM,C+A%5	 HH
NNfr=   c                (    V ^8  d   QhR\         RR/# )r6   	exc_valuer8   r!  )BaseException)r:   s   "r;   r<   r<     s     - - -? -r=   c                     \        V R R4      # )errnoNrQ  )r  s   &r;   	get_errnor    s    9gt,,r=   c                (    V ^8  d   QhRRR\         /# )r6   r  r   r8   r   )r:   s   "r;   r<   r<     s      !: s r=   c                 4   \        \        V R R4      ;'       g!    \        V RR4      ;'       g    \        V 4      4      p\        V RR4      p\        V\        4      '       d7   \	        V4      ^ 8  d'   VRRP                  R V 4       4      ,           ,          pV# )messager   detail	__notes__N
c              3   V   "   T F  p\        V\        4      '       g   K  Vx  K!  	  R # 5ir   )r   r?   )rC  notes   & r;   rE  $get_error_message.<locals>.<genexpr>  s     #TUTjs>SDDUs   )
))r  rR  r   listr~  r  )r  r  notess   &  r;   get_error_messager    s    	9b) 	 	9h+	 	IG I{D9E%3u:>4$))#TU#TTTTNr=   c                @    V ^8  d   QhRRRRRRRRR	RR
RRRRRRRRR/
# )r6   exc_typerO  r  r   r   r   client_optionsOptional[Dict[str, Any]]	mechanismexception_idrp  	parent_idr  rV   
full_stackOptional[list[dict[str, Any]]]r8   r  r9   )r:   s   "r;   r<   r<     sx     c cc(c 	"c /	c
 *c "c c c 1c cr=   c	                h   / p	V'       d   VP                  4       MRRRR/V	R&   Ve   WYR,          R&   Ve   \        V4      p
MRp
V
e:   V	R,          P                  R/ 4      P                  R	/ 4      P                  R
V
4       Ve   WyR,          R&   V^ 8H  pV'       g   Ve   WiR,          R&   RV	R,          R&   V'       d   RV	R,          9  d   RV	R,          R&   \        RJ;'       d    \	        V\        4      pV'       d   RV	R,          R&   \        V 4      V	R&   \        V 4      V	R&   \        V4      V	R&   Vf   RpRp\        pRpM,VR,          pVR,          pVR,          pVP                  R4      p\        \        V4      \        \        ^,           4      4       UUu. uF+  w  pp\        VP                  VP                   VVVVR7      NK-  	  ppp\#        V4      \        8  d   \$        P&                  ! RR7      V	R&   V	# V'       d   V'       g   TpM\)        VW4      pRV/V	R&   V	# u uppi )z
Creates a dict that goes into the events `exception.values` list and is ingestible by Sentry.

See the Exception Interface documentation for more details:
https://develop.sentry.dev/sdk/event-payloads/exception/
r7  generichandledTr  Nr  metar  numberr  r  chainedis_exception_grouprr  r7   r  r  r  r  )r  r  r  r  r  r   
stacktracer  )copyr  
setdefaultr   r   rY  rS  r  r   r   ziprk  rangeMAX_STACK_FRAMESr  rh  r  r~  r   removed_because_over_size_limitmerge_stack_frames)r  r  r   r  r  r  r  r  r  exception_valuer  is_root_exceptionr  r  r  r  r  _r  
new_framess   &&&&&&&&&           r;   !single_exception_from_error_tupler    sf   " )+O%	FIy$+O K  7C$^4)$$//;FFR	

*Xu
%17$X.$)!64=$[1/8$V,V?;+GG/8$V,+47  J%= =A$%9: / 9OH+H5OF0;OG"&!%3"01J"K!/0H!I)*<=$((7 R%0@10D*EF& GEB 	KKll$;#9-#	
 G  & 6{%% )7(V(V)
%  
J+FJOJ)1:(>%C&s   "1H.__suppress_context__c                     V ^8  d   QhRRRR/# r6   r   r.   r8   zIterator[ExcInfo]r9   )r:   s   "r;   r<   r<     s     7 7y 75H 7r=   c              #   d  "   V w  rp. p\        4       pVe   Ve   \        V4      V9  d   WV3x  VP                  V4       VP                  \        V4      4       VP                  '       d   VP
                  pMVP                  pVf   R # \        V4      pTp\        VRR 4      pK  R # R # R # 5i)N__traceback__)	setidrG  addr  	__cause____context__r7  rR  )r   r  r  r   seen_exceptionsseen_exception_idscauses   &      r;   walk_exception_chainr    s     "*R),  %9%77r))
 ""9-""2i=1---!++!--}E{HI6B% 8 & !s   B.B0c                     V ^8  d   QhRRRR/# r  r9   )r:   s   "r;   r<   r<     s      y 5H r=   c              #      "   V x  R # 5ir   r9   r   s   &r;   r  r    s
     s   	c                P    V ^8  d   QhRRRRRRRRR	RR
\         R\         RRRRRR/
# )r6   r  rO  r  r   r   r   r  r  r  r  r  r  rV   r  r  r8   z Tuple[int, List[Dict[str, Any]]]r  )r:   s   "r;   r<   r<   "  sx     c& c&c&(c& 	"c& /	c&
 *c& c& c& c& 1c& (c&r=   c	                   \        V VVVVVVVVR7	      p	V	.p
TpV^,          p\        VR4      ;'       d    VP                  pV'       d|   T;'       d#    \        VR4      ;'       d    VP                  RJpV'       dG   VP                  p\	        \        V4      V\        VRR4      VVVRVR7      w  r^V
P                  V4       MzT;'       d#    \        VR4      ;'       d    VP                  RJpV'       dG   VP                  p\	        \        V4      V\        VRR4      VVVRVR7      w  r^V
P                  V4       T;'       d    \        VR4      pV'       db   \        VP                  4       FH  w  pp\	        \        V4      V\        VRR4      VVVVR	V,          VR7	      w  r^V
P                  V4       KJ  	  WZ3# )
z
Creates the list of exceptions.
This can include chained exceptions and exceptions from an ExceptionGroup.

See the Exception Interface documentation for more details:
https://develop.sentry.dev/sdk/event-payloads/exception/
)	r  r  r   r  r  r  r  r  r  r  r  Nr  )r  r  r   r  r  r  r  r  r  
exceptionszexceptions[%s])r  rw  r  r  exceptions_from_errorr7  rR  extendr  	enumerater  )r  r  r   r  r  r  r  r  r  parentr  should_supress_contextexception_has_causer  child_exceptionsexception_has_contentcontextr  idxes   &&&&&&&&&           r;   r  r  "  s   & /%!
F JIAL 		12UUy7U7U    0 0	;/0 0##4/ 	
 ''E/De5/48-#)"%	0,\ ./  2 2	=12 2%%T1 	
 !++G/Dg!7OT:-#)$%	0,\ ./ #GGwy,'G	 4 45FC/Da1ot4-#)#'#-%
0,\ ./ 6 %%r=   c          
      ,    V ^8  d   QhRRRRRRRRRR	/# )
r6   r   r.   r  r  r  r  r  r8   List[Dict[str, Any]]r9   )r:   s   "r;   r<   r<     s:     ( ((.( *( 1	(
 (r=   c                    V w  rEp\         R J;'       d    \        V\         4      pV'       d   \        VVVVV^ ^ VR7      w  rM7. p	\        V 4       F&  w  rEpV	P	                  \        VVVVVVR7      4       K(  	  V	P                  4        V	# )N)r  r  r   r  r  r  r  r  )r  r  r   r  r  r  )r   r   r  r  rG  r  r  )
r   r  r  r  r  r  r   r  r  r  s
   &&&&      r;   exceptions_from_error_tupler    s     'H+47  J%= /)!	
J 
';H'E#H1%'#1')	 (F r=   c                0    V ^8  d   QhR\         R\         /# )r6   r7   r8   r   )r:   s   "r;   r<   r<     s     ! !S !S !r=   c                 X     \        V 4      #   \         d    \        T 4      ^R u # i ; i)r   r   )r?   UnicodeDecodeErrorr  r   s   &r;   	to_stringr    s1    !5z !E{1R  !s   
 ))c                     V ^8  d   QhRRRR/# )r6   eventr-   r8   z#Iterator[Annotated[Dict[str, Any]]]r9   )r:   s   "r;   r<   r<     s     
. 
.' 
..S 
.r=   c              #   v  "   R V 9   d   V R ,          x  RV 9   d>   V R,          P                  R4      ;'       g    R F  pR V9   g   K  VR ,          x  K  	  RV 9   dX   V R,          P                  R4      ;'       g    R F/  p\        V\        4      '       g   K  R V9   g   K$  VR ,          x  K1  	  R# R# 5i)r  threadsvalues	exceptionNr9   )r   r   r   )r  threadr  s   &  r;   iter_event_stacktracesr    s     uL!!EI&**84:::Fv%\** ; e{+//9??R?I)T**|y/H-- @ s"   8B9
B9
4B9?B9B9&B9c                     V ^8  d   QhRRRR/# )r6   r  r-   r8   zIterator[Dict[str, Any]]r9   )r:   s   "r;   r<   r<     s      W )C r=   c              #      "   \        V 4       FU  p\        V\        4      '       d   VP                  ;'       g    / pVP	                  R 4      ;'       g    R F  pVx  K	  	  KW  	  R# 5i)r  Nr9   )r  r   r   r7   r   )r  r  r[  s   &  r;   iter_event_framesr    sW     ,U3
j.11#))//RJ^^H-333EK 4	 4s   7A)A)A)c          
      ,    V ^8  d   QhRRRRRRRRRR/# )	r6   r  r-   in_app_excludeOptional[List[str]]in_app_includeproject_rootrV   r8   r9   )r:   s   "r;   r<   r<     s:      ) * "	
 r=   c                     \        V 4       FM  p\        V\        4      '       d   VP                  ;'       g    / p\	        VP                  R 4      VVVR7       KO  	  V # )r  )r!  r#  r$  )r  r   r   r7   set_in_app_in_framesr   )r  r!  r#  r$  r  s   &&&& r;   handle_in_appr'    sW     -U3
j.11#))//RJNN8$))%		
	 4 Lr=   c          
      ,    V ^8  d   QhRRRRRRRRRR	/# )
r6   r  r   r!  r"  r#  r$  rV   r8   r!  r9   )r:   s   "r;   r<   r<     s:     ( (()( *( "	(
 (r=   c                 j   V '       g   R # V  F  pVP                  R4      pVe   K  VP                  R4      p\        Wb4      '       d   RVR&   KC  \        Wa4      '       d   RVR&   K[  VP                  R4      pVf   Kr  \        V4      '       d   RVR&   K  \        Ws4      '       g   K  RVR&   K  	  V # )Nin_apprr  TFr  )r   _module_in_list_is_external_source_is_in_project_root)r  r!  r#  r$  r[  current_in_apprr  r  s   &&&&    r;   r&  r&    s     8,%8$ 622"E(O 622#E(O 99Z(x((#E(Ox66"E(O; > Mr=   c                     V ^8  d   QhRRRR/# )r6   r   Union[BaseException, ExcInfo]r8   r.   r9   )r:   s   "r;   r<   r<     s      > 9 r=   c                    \        V \        4      '       d   \        V 4      ^8X  d   V w  rpM}\        V \        4      '       dM   \	        V RR4      pVe   \        V 4      pT pMH\        P                  ! 4       w  rpW Jd   RpT p\        V 4      pM\        R\        V 4      ,          4      hWV3p\        '       d   \        \        V4      pV# )   r  Nz,Expected Exception object to report, got %s!)r   tupler~  r  rR  r7  rd   r   r   r   r*   r.   )r   r  r  r   r   s   &    r;   r   r     s    %CJ!O"'R	E=	)	)UOT2>E{HI&)lln#H%!	; G$u+UVVR(H} *Or=   c                (    V ^8  d   QhRRRRRRRR/# )r6   r  r  r  r  r  r8   r9   )r:   s   "r;   r<   r<   +  s0     ( ("(&( /( 	(r=   c                   V  Uu0 uF%  pVR,          VR,          VR,          VR,          3kK'  	  ppV Uu. uF.  pVR,          VR,          VR,          VR,          3V9  g   K,  VNK0  	  ppVP                  V 4       V'       d   VP                  R\        4      MRpVe   V\        V4      V,
          R pV# u upi u upi )zN
Add the missing frames from full_stack to frames and return the merged list.
r  r  rn  r  max_stack_framesN)r  r   r   r~  )r  r  r  r[  	frame_ids
stackframer  r6  s   &&&     r;   r  r  +  s      E *.!(O*		
    %
$Jz"~&x z"	
  	
$  
 f
  	-/GH 
 #J2B B DE
A
s   +B8)B=$B=c                (    V ^8  d   QhRRRRRRRR/# )r6   r   r0  r  r  r  r8   zTuple[Event, Dict[str, Any]]r9   )r:   s   "r;   r<   r<   V  s0      -. * $	r=   c           
          \        V 4      p \        V 4      pV'       d@   VP                  R \        4      '       d$   \	        VR,          VR,          R7      R,          pMRpRRRR	\        WW$4      //V3# )
add_full_stackr  r  )r  r  r  Nlevelr   r  r  )r   r   r   r   r  r  )r   r  r  hintr  s   &&&  r;   event_from_exceptionr>  V  s    
 #8,H#H-D.,,-=?UVV'$23L$M+,>?
 

 
 W5i	
 	
 
r=   c                ,    V ^8  d   QhRRRRR\         /# )r6   namerV   itemsr"  r8   r   )r:   s   "r;   r<   r<   s  s"      / 2G D r=   c                     V f   R# V'       g   R# V F*  pW 8X  g!   V P                  VR,           4      '       g   K)   R# 	  R# )NFr   Tr`  )r@  rA  items   && r;   r+  r+  s  s9    |<4??4#:66  r=   c                (    V ^8  d   QhRRR\         /# )r6   r  rV   r8   r   )r:   s   "r;   r<   r<     s      / d r=   c                 D    V f   R# \         P                  ! RV 4      R JpV# )NFz [\\/](?:dist|site)-packages[\\/]r,  search)r  external_sources   & r;   r,  r,    s.     			5x@L  r=   c                ,    V ^8  d   QhRRRRR\         /# )r6   r  rV   r$  r8   r   )r:   s   "r;   r<   r<     s$     
 

-<
	
r=   c                 L    V e   Vf   R# V P                  V4      '       d   R# R# )NFTrC  )r  r$  s   &&r;   r-  r-    s+     </ <((r=   c                <    V ^8  d   QhR\         R\        R\         /# )r6   string	max_bytesr8   r2  )r:   s   "r;   r<   r<     s!      s s s r=   c                l    V P                  R4      RV^,
           P                  RRR7      pVR,           # )z\
Truncate a UTF-8-encodable string to the last full codepoint so that it fits in max_bytes.
rM   Nignore)errors...)rR   rn   )rM  rN  	truncateds   && r;   _truncate_by_bytesrT    s8     g&Q7>>wx>XIur=   c                (    V ^8  d   QhR\         RR/# )r6   r7   r8   rp  r   )r:   s   "r;   r<   r<     s      c o r=   c                 h     \        V P                  R 4      4      #   \        \        3 d     R# i ; i)rM   N)r~  rR   UnicodeEncodeErrorr  r   s   &r;   _get_size_in_bytesrX    s3    5<<()) 23 s    11c                ,    V ^8  d   QhR\         RRRR/# )r6   r7   ro  rp  r8   zUnion[AnnotatedValue, str]r   )r:   s   "r;   r<   r<     s$      +!r=   c           
         V '       g   V # Vf   \         p\        V 4      p\        V 4      pVe   W!8  d   \        W4      pM Ve   W18  d   V R V^,
           R,           pMV # \	        TRT;'       g    TRRRV^,
          V../R7      # )NrR  r~  remz!limitx)r7   metadata)r   rX  r~  rT  r   )r7   ro  	byte_size	text_sizetruncated_values   &&   r;   r  r    s     -
"5)IE
I!7,U?		9#9 0*q.1E99))	XsJNJ?@
 r=   c                (    V ^8  d   QhR\         RR/# )r6   r1  r8   Optional[Tuple[int, ...]]r   )r:   s   "r;   r<   r<     s     0 03 0#> 0r=   c                   Rp\         P                  ! RV,           R,           \         P                  \         P                  ,          4      p VP	                  V 4      P                  4       R,          p\        \        \        VP                  R4      R,          4      4      pV#   \        \        \        3 d     R# i ; i)z
Parses a version string into a tuple of integers.
This uses the parsing loging from PEP 440:
https://peps.python.org/pep-0440/#appendix-b-parsing-version-strings-with-regular-expressions
a    # noqa: N806
        v?
        (?:
            (?:(?P<epoch>[0-9]+)!)?                           # epoch
            (?P<release>[0-9]+(?:\.[0-9]+)*)                  # release segment
            (?P<pre>                                          # pre-release
                [-_\.]?
                (?P<pre_l>(a|b|c|rc|alpha|beta|pre|preview))
                [-_\.]?
                (?P<pre_n>[0-9]+)?
            )?
            (?P<post>                                         # post release
                (?:-(?P<post_n1>[0-9]+))
                |
                (?:
                    [-_\.]?
                    (?P<post_l>post|rev|r)
                    [-_\.]?
                    (?P<post_n2>[0-9]+)?
                )
            )?
            (?P<dev>                                          # dev release
                [-_\.]?
                (?P<dev_l>dev)
                [-_\.]?
                (?P<dev_n>[0-9]+)?
            )?
        )
        (?:\+(?P<local>[a-z0-9]+(?:[-_\.][a-z0-9]+)*))?       # local version
    z^\s*z\s*$r   r   :Nr2  NN)r,  r-  VERBOSE
IGNORECASEr  	groupdictr3  mapr  r  r  r   r   )r1  VERSION_PATTERNpatternr   release_tuples   &    r;   parse_versionrk    s    O> jj/!G+


R]]"G
--(224Y?+0S'--:LR:P1Q+R  z>2 s   AB# #B=<B=c                $    V ^8  d   QhR\         /# r  r   )r:   s   "r;   r<   r<     s     0 0 0r=   c                 "    ^ RI p ^ RIHp \        \        P
                  ! RV P                  4      R,           Uu. uF  p\        V4      NK  	  up4      pV! RR4      '       d0   \        P                  R8  d   VR8  g   V! RR4      '       d   R	# R
#   ^ RIp^ RIHp \        VP                  4      pVf   \        P!                  R4       R	# V! R4      '       d
   VR8  d   R
# R	# u upi   \         d     Lfi ; i  \         d     R	# i ; i)z
Returns whether gevent/eventlet have patched the stdlib in a way where thread locals are now more "correct" than contextvars.
N)is_object_patchedz	a|b|rc|\.:Nr6   N	threadinglocalcontextvars
ContextVarFT)is_monkey_patchedzYInternal error in Sentry SDK: Could not parse Greenlet version from greenlet.__version__.r  r2  rJ  )   	   )r   ru  )geventgevent.monkeyrn  r3  r,  r  __version__r  rd   version_inforx  greenleteventlet.patcherrs  rk  r   r   )rw  rn  partversion_tupler{  rs  greenlet_versions          r;   _is_contextvars_brokenr    s   3 #%88L&:L:L#Mb#QR#Q4SY#QR
 ['22 !!V+0H%m\BB 3&6()=)=>#LLk X&&+;f+D M S$  "  sF   9C. C)C. %*C. 8C? C? C? )C. .C<;C<?DDc                0    V ^8  d   QhR\         R\         /# )r6   rp  r8   )r7  )r:   s   "r;   r<   r<   -  s       $ r=   c                 "   a   ! V 3R  lR4      pV# )c                   x   <a  ] tR tRt o RV 3R lV3R llltRV 3R lR lltV 3R lR ltV 3R	 lR
 ltRtV t	R# )1_make_threadlocal_contextvars.<locals>.ContextVari.  Nc                (   < V ^8  d   QhRS[ RRRR/# )r6   r@  defaultr   r8   Nr   )r:   r   s   "r;   r<   >_make_threadlocal_contextvars.<locals>.ContextVar.__annotate__1  s"     	+ 	+ 	+u 	+ 	+r=   c                P   < Wn         W n        S! 4       V n        S! 4       V n        R # r   )_name_default_local_original_local)r   r@  r  rp  s   &&&r;   r  :_make_threadlocal_contextvars.<locals>.ContextVar.__init__1  s     J#M'DK#(7D r=   c                "   < V ^8  d   QhRRRR/# )r6   r  r   r8   r9   )r:   r   s   "r;   r<   r  7  s     	K 	Ku 	K 	Kr=   c                X    \        V P                  R T;'       g    V P                  4      # r   )rR  r  r  )r   r  s   &&r;   r   5_make_threadlocal_contextvars.<locals>.ContextVar.get7  s!    4;;1I1IDMMJJr=   c                "   < V ^8  d   QhRRRR/# r  r9   )r:   r   s   "r;   r<   r  :  s     	 	U 	u 	r=   c                    \        \        P                  ! ^@4      4      pV P                  4       p\	        V P
                  W#4       WP                  n        V# )@   )r?   randomgetrandbitsr   setattrr  r  r7   )r   r7   tokenoriginal_values   &&  r;   r  5_make_threadlocal_contextvars.<locals>.ContextVar.set:  sA    **2./E!XXZND((%@ %KKLr=   c                "   < V ^8  d   QhRRRR/# )r6   r  r   r8   Nr9   )r:   r   s   "r;   r<   r  A  s     	5 	5u 	5 	5r=   c                ~    \        V P                  V4      V P                  n        V P                  P                  V R # r   )rR  r  r  r7   r  )r   r  s   &&r;   reset7_make_threadlocal_contextvars.<locals>.ContextVar.resetA  s/     '(<(<e DDKK$$--e4r=   )r  r  r  r  r   )
r   r   r   r   r  r   r  r  r   r   )r   rp  s   @r;   rr  r  .  s/     	+ 	+	K 	K	 		5 	5r=   rr  r9   )rp  rr  s   f r;   _make_threadlocal_contextvarsr  -  s    5 50 r=   c                    V ^8  d   QhRR/# )r6   r8   zTuple[bool, type]r9   )r:   s   "r;   r<   r<   I  s     "7 "7- "7r=   c                     \        4       '       g,   \        P                  R8  d    ^ RIHp  RV 3#  ^ RIHp  RV 3# ^ RIHp R\        V4      3#   \
         d     L i ; i  \
         d     L1i ; i)z
Figure out the "right" contextvars installation to use. Returns a
`contextvars.ContextVar`-like class with a limited API.

See https://docs.sentry.io/platforms/python/contextvars/ for more information.
)rr  T)rp  Frt  )
r  rd   rz  aiocontextvarsrr  rx  rq  ro  rp  r  )rr  rp  s     r;   _get_contextvarsr  I  s     "##
 f$5Z''
2Z''  /666    s"   	A 	A  AA A.-A.z

With asyncio/ASGI applications, the Sentry SDK requires a functional
installation of `contextvars` to avoid leaking scope/context data across
requests.

Please refer to https://docs.sentry.io/platforms/python/contextvars/ for more information.
c                     V ^8  d   QhRRRR/# r6   funczCallable[..., Any]r8   rV   r9   )r:   s   "r;   r<   r<   z  s     ( (!5 (/ (r=   c                   Rp V P                   P                  : RV P                   P                  : RV P                  : 2#   \         d     Mi ; iRRr2\	        T \
        4      '       d-   \        T P                  R4      '       d   RRr2T P                  p MG\        T RR4      ;'       g    \        T RR4      p\	        T\        4      '       d   R	Rr2TP                  p \        T R
4      '       d   T P                  pM\        T R4      '       d   T P                  pTe\   \        T R4      '       d;   \	        T P                  \        4      '       d   T P                  R,           T,           pY!,           T,           pT# )zbReturn the qualified name of func. Works with regular function, lambda, partial and partialmethod.Nr   r   r   zpartial(<function z>)_partialmethod__partialmethod__zpartialmethod(<function r   r   )im_classr   r   rc  r   r   rw  r  rR  r   r   r?   )r  func_qualnameprefixsuffixpartial_methods   &    r;   qualname_from_functionr  z  sF   %)MMM$$MM""MM
 	

   F$  WTYY
%C%C-tyy !'7> 
 
'%tC
 nm447F!&&Dt^$$))	z	"	"  4&&:doos+K+K OOc1MAM.7s   >A AAc                     V ^8  d   QhRRRR/# r  r9   )r:   s   "r;   r<   r<     s     ( ($8 (_ (r=   c                     \        V 4      # r   )r  )r  s   &r;   transaction_from_functionr    s    !$''r=   disable_capture_eventc                       ] tR tRtRtRtR# )ServerlessTimeoutWarningi  z>Raised when a serverless method is about to reach its timeout.r9   Nr   r9   r=   r;   r  r    s    Hr=   r  c                   p   a  ] tR tRt o RtRV 3R lR lltV 3R lR ltV 3R lR	 ltV 3R
 lR ltRt	V t
R# )TimeoutThreadi  zCreates a Thread which runs (sleeps) for a time duration equal to
waiting_time and raises a custom ServerlessTimeout exception.
Nc          
      2   < V ^8  d   QhRS[ RS[RRRRRR/# )r6   waiting_timeconfigured_timeoutisolation_scopezOptional[sentry_sdk.Scope]current_scoper8   N)r   r  )r:   r   s   "r;   r<   TimeoutThread.__annotate__  s=     - --  - 6	-
 4- 
-r=   c                    \         P                  P                  V 4       Wn        W n        W0n        W@n        \         P                  ! 4       V n        R # r   )	ro  Threadr  r  r  r  r  r-   _stop_event)r   r  r  r  r  s   &&&&&r;   r  TimeoutThread.__init__  s?     	!!$'("4.*$??,r=   c                   < V ^8  d   QhRR/# r6   r8   Nr9   )r:   r   s   "r;   r<   r    s      d r=   c                :    V P                   P                  4        R # r   )r  r  r   s   &r;   stopTimeoutThread.stop  s    r=   c                   < V ^8  d   QhRR/# )r6   r8   r.   r9   )r:   r   s   "r;   r<   r    s      I r=   c                    \         P                  ! 4       p\        P                  ! 4       p\	        VVP
                  R RRR/R7      w  r4\        P                  ! W4R7       V# )r7  ro  r  F)r  r  )r=  )rd   r   r   r   r>  optionscapture_event)r   r   r   r  r=  s   &    r;   _capture_exception TimeoutThread._capture_exception  sR    <<>&&(*!>>{Iu=

 	  2r=   c                   < V ^8  d   QhRR/# r  r9   )r:   r   s   "r;   r<   r    s     
 
T 
r=   c           	        V P                   P                  V P                  4       V P                   P                  4       '       d   R # \	        V P
                  4      pWP
                  8  d
   V^,           pV P                  e   V P                  e   \        P                  P                  V P                  4      ;_uu_ 4        \        P                  P                  V P                  4      ;_uu_ 4         \        RP                  V4      4      h\        RP                  V4      4      h  \         d    \        T P!                  4       !    Mi ; i R R R 4       M  + '       g   i     M; iR R R 4       Ki    + '       g   i     Ly; i)NzZWARNING : Function is expected to get timed out. Configured timeout duration = {} seconds.)r  waitr  is_setr  r  r  r  r   scopeuse_isolation_scope	use_scoper  r:   rc  reraiser  )r   integer_configured_timeouts   & r;   runTimeoutThread.run  s9   d//0""$$%()@)@%A" &(?(??)Ca)G& +0B0B0N!!55d6J6JKK%%//0B0BCC<6x :  'hoo*
 	
 % <!8!8!:;<; DCCC LKKKsB   2E:5E	7D++"EE	EE		E:E-(E::F
	)r  r  r  r  r  NN)r   r   r   r   r   r  r  r  r  r   r   r   s   @r;   r  r    s2     - -   
 
r=   r  c                (    V ^8  d   QhR\         RR/# )r6   originalr8   rV   r   )r:   s   "r;   r<   r<     s        r=   c                    Rp V P                  R4      p\        P                  ! V4      pVP                  R4      pV#   \         d2   p\
        P                  RP                  T R7      T4        Rp?T# Rp?ii ; i)zG
Convert a string to base64, via UTF-8. Returns None on invalid input.
NUTF-8z"Unable to encode {orig} to base64:)orig)rR   base64	b64encodern   rc  r   warningr:   )r  base64_string
utf8_bytesbase64_byteserrs   &    r;   	to_base64r    s     MX__W-
''
3$++G4   X;BBBQSVWWXs   8> A:	&A55A:c                (    V ^8  d   QhR\         RR/# )r6   r  r8   rV   r   )r:   s   "r;   r<   r<     s      s  r=   c                8   Rp \         P                  V 4      pV'       g   Q hV P                  R4      p\        P                  ! V4      pVP                  R4      pV#   \         d2   p\        P                  RP                  T R7      T4        Rp?T# Rp?ii ; i)zI
Convert a string from base64, via UTF-8. Returns None on invalid input.
Nr  z#Unable to decode {b64} from base64:)b64)
BASE64_ALPHABETr  rR   r  	b64decodern   rc  r   r  r:   )r  utf8_stringonly_valid_charsr  r  r  s   &     r;   from_base64r    s     K

*00?$++G4%%l3
 ''0   
188]8KS	
 	
 
s   A :A B(&BB
Componentsc          
      L    V ^8  d   QhR\         R\        R\        R\        RR/# )r6   urlremove_authorityremove_query_valuesr  r8   zUnion[str, Components]r?   rC   )r:   s   "r;   r<   r<     s:     -& -&	-&-& -& 	-&
 -&r=   c           	     "   \        V 4      p\        VP                  RR7      pV'       dV   VP                  P	                  R4      p\        V4      ^8  d   \        : R\        : RVR,          : 2pMVP                  pMVP                  pV'       d*   \        \        V Uu/ uF	  q\        bK  	  up4      4      p	MVP                  p	\        VP                  VV	VP                  VP                  R7      p
V'       d   V
# \        V
4      # u upi )zD
Removes the authority and query parameter values from a given URL.
T)keep_blank_valuesr)  rO   r  r  queryrb   fragmentr   )r   r   r  r  r  r~  r   r   r   r  r  rb   r  r   )r  r  r  r  
parsed_urlquery_paramsnetloc_partsr  rD  query_string
componentss   &&&&       r;   sanitize_urlr    s     #JJ,,EL !((..s3|q ))R F  &&F"" N#55NO
 "''  __$$J *%%! Os   "D	ParsedUrlc                4    V ^8  d   QhR\         R\        RR/# )r6   r  sanitizer8   r  r  )r:   s   "r;   r<   r<   R  s!      3 $ + r=   c           
         \        V RVRR7      p\        \        VP                  VP                  RVP
                  RR7      4      p\        VVP                  VP                  R7      # )z
Splits a URL into a url (including path), query and fragment. If sanitize is True, the query
parameters will be sanitized to remove sensitive data. The autority (username and password)
in the URL will always be removed.
T)r  r  r  r   r  r  r  r  )	r  r   r  r  r  rb   r  r  r  )r  r   r  base_urls   &&  r;   	parse_urlr  R  sn     dJ $$$$	
H $$ r=   c                4    V ^8  d   QhRRR\         R\        /# )r6   rater   r  r8   r  )r:   s   "r;   r<   r<   m  s!      u c d r=   c           	     X   \        V \        \        34      '       d   \        P                  ! V 4      '       d2   \
        P                  RP                  W\        V 4      R7      4       R# \        V 4      p V ^ 8  g   V ^8  d(   \
        P                  RP                  WR7      4       R# R# )zz
Checks the given sample rate to make sure it is valid type and value (a
boolean or a number between 0 and 1, inclusive).
z|{source} Given sample rate is invalid. Sample rate must be a boolean or a number between 0 and 1. Got {rate} of type {type}.)r  r  r7  FzW{source} Given sample rate is invalid. Sample rate must be between 0 and 1. Got {rate}.)r  r  T)
r   r
   r   mathisnanr   r  r:   r7  r   )r  r  s   &&r;   is_valid_sample_rater
  m  s     dT7O,,

40@0@ K  R  RtDz R 	

  ;Dax4!8ell m 	

 r=   c                @    V ^8  d   QhR\         RRR\        R\        /# )r6   rD  
regex_listr"  substring_matchingr8   r  )r:   s   "r;   r<   r<     s0      
%  
	r=   c                     Vf   R# V FC  pV'       g   VR,          R8w  d
   VR,          p\         P                  ! W04      pV'       g   KB   R# 	  R# )NF$Tr   rG  )rD  r  r  item_matchermatcheds   &&&  r;   match_regex_listr    sK    
 "!l2&6#&=CL))L/7 # r=   c                4    V ^8  d   QhRRR\         R\        /# )r6   r   zsentry_sdk.client.BaseClientr  r8   r  )r:   s   "r;   r<   r<     s"     	 	8 	s 	t 	r=   c                    V RJ;'       dZ    V P                   RJ;'       dD    V P                   P                  RJ;'       d$    V P                   P                  P                  V9   # )z:
Determines whether the given URL matches the Sentry DSN.
N)	transport
parsed_dsnr  )r   r  s   &&r;   is_sentry_urlr    sm    
 	d 	6 	6D(	6 	6''t3	6 	6 ''..#5	r=   c                    V ^8  d   QhRR/# )r6   r8   zIterator[Tuple[str, str]]r9   )r:   s   "r;   r<   r<     s     A A%@ Ar=   c               #     "    ^ RI Hp  \        4       pV P                  4        Fh  pVP                  P	                  RR4      pVf   K%  \        V4      pVP                  f   K@  WA9  g   KH  WBP                  3x  VP                  V4       Kj  	  R#   \         dT     ^ RI	pM  \         d      R# i ; iTP                   F&  p\        TP                  4      TP                  3x  K(  	   R# i ; i5i)r   )r]  NameN)	importlibr]  r  distributionsr   _normalize_module_namer1  r  rx  pkg_resourcesworking_setrD  )r]  yieldeddistr@  normalized_namer  infos          r;   _generate_installed_modulesr$    s     A&%**,D==$$VT2D
 "8"><<+0N)<<77KK0 -  A	  		 "--D(2DLL@@ .Ase   C3A B 	B $B ,$B C3C0B#"C0#B3.C0/C32B339C0,C3/C00C3c                0    V ^8  d   QhR\         R\         /# r6   r@  r8   r   )r:   s   "r;   r<   r<     s        r=   c                 "    V P                  4       # r   )r@   r@  s   &r;   r  r    s    ::<r=   c                0    V ^8  d   QhR\         R\         /# r&  r   )r:   s   "r;   r<   r<     s     ( (C (C (r=   c                 2    \         P                  ! R RV 4      # )z[-_.]+-)r,  subr(  s   &r;   1_replace_hyphens_dots_and_underscores_with_dashesr-    s    66)S$''r=   c                    V ^8  d   QhRR/# )r6   r8   zDict[str, str]r9   )r:   s   "r;   r<   r<     s       0 r=   c                  D    \         f   \        \        4       4      s \         # r   )_installed_modulesr   r$  r9   r=   r;   _get_installed_modulesr1    s    !!"="?@r=   c                (    V ^8  d   QhR\         RR/# )r6   packager8   rb  r   )r:   s   "r;   r<   r<     s     " "S "%@ "r=   c                     \        \        V 4      4      p\        4       P                  4        UUu/ uF  w  r#\        V4      VbK  	  pppVP	                  V4      pVf   R # \        V4      # u uppi r   )r  r-  r1  rA  r   rk  )r3  normalized_packagerr  vinstalled_packagesr1  s   &     r;   package_versionr8    sz    /9'B 017799IF 	:&A1D9   !$$%78G!!s   A,c                (    V ^8  d   QhRRRRRRRR/# )	r6   tpr   r7   r   r   r!  r8   r"   r9   )r:   s   "r;   r<   r<     s0      '$ 	 	r=   c                 T    Vf   Q hVP                   VJd   VP                  V4      hVhr   )r  with_traceback)r:  r7   r   s   &&&r;   r  r    s4    
 "$""2&&
Kr=   c                $    V ^8  d   QhRRRRRR/# )r6   _ar   _kr8   Nr9   )r:   s   "r;   r<   r<     s!     	 	 	U 	t 	r=   c                     R# )z.No-op function for ensure_integration_enabled.Nr9   )r>  r?  s   *,r;   _no_oprA    s    r=   c                $    V ^8  d   QhRRRRRR/# )r6   r   )type[sentry_sdk.integrations.Integration]original_functionCallable[P, R]r8   *Callable[[Callable[P, R]], Callable[P, R]]r9   )r:   s   "r;   r<   r<     s&     ; ;@;+; 
6;r=   c                     R # r   r9   )r   rD  s   &&r;   ensure_integration_enabledrH    s     8;r=   c                     V ^8  d   QhRRRR/# )r6   r   rC  r8   z0Callable[[Callable[P, None]], Callable[P, None]]r9   )r:   s   "r;   r<   r<     s      A A@A	;Ar=   c                     R # r   r9   )r   s   &r;   rH  rH    s     >Ar=   c                $    V ^8  d   QhRRRRRR/# )r6   r   rC  rD  z(Union[Callable[P, R], Callable[P, None]]r8   rF  r9   )r:   s   "r;   r<   r<     s&     * *<*A* 2*r=   c                x   a a \         '       d"   \        \        \        \        3,          S4      oR V V3R llpV# )aG  
Ensures a given integration is enabled prior to calling a Sentry-patched function.

The function takes as its parameters the integration that must be enabled and the original
function that the SDK is patching. The function returns a function that takes the
decorated (Sentry-patched) function as its parameter, and returns a function that, when
called, checks whether the given integration is enabled. If the integration is enabled, the
function calls the decorated, Sentry-patched function. If the integration is not enabled,
the original function is called.

The function also takes care of preserving the original function's signature and docstring.

Example usage:

```python
@ensure_integration_enabled(MyIntegration, my_function)
def patch_my_function():
    with sentry_sdk.start_transaction(...):
        return my_function()
```
c                     V ^8  d   QhRRRR/# )r6   sentry_patched_functionrE  r8   r9   )r:   s   "r;   r<   0ensure_integration_enabled.<locals>.__annotate__"  s     
0 
0)9 
0>N 
0r=   c                 t   <a  R  VVV 3R llpS\         J d   \        S 4      ! V4      # \        S4      ! V4      # )c                $    V ^8  d   QhRRRRRR/# )r6   argszP.argskwargszP.kwargsr8   r3   r9   )r:   s   "r;   r<   Aensure_integration_enabled.<locals>.patcher.<locals>.__annotate__#  s!     	< 	<( 	<j 	<S 	<r=   c                  p   < \         P                  ! 4       P                  S4      f	   S! V / VB # S! V / VB # r   )r   r   get_integration)rR  rS  r   rD  rN  s   *,r;   runner;ensure_integration_enabled.<locals>.patcher.<locals>.runner#  s=    $$&66{CK($9&99*D;F;;r=   )rA  r	   )rN  rW  r   rD  s   f r;   patcher+ensure_integration_enabled.<locals>.patcher"  s9    	< 	< &01&99&'//r=   )r   r*   r   r2   r3   )r   rD  rY  s   ff r;   rH  rH    s3    2 } !!Q$1BC
0 
0 Nr=   c                $    V ^8  d   QhR\         /# r  r  )r:   s   "r;   r<   r<   3  s     & &S &r=   c                  ,    \         P                  ! 4       # r   )timeperf_counter_nsr9   r=   r;   nanosecond_timer_  3  s    ##%%r=   c                $    V ^8  d   QhR\         /# r  r  )r:   s   "r;   r<   r<   8  s     . .S .r=   c                  L    \        \        P                  ! 4       R ,          4      # )g    eA)r  r]  perf_counterr9   r=   r;   r_  r_  8  s    4$$&,--r=   c                $    V ^8  d   QhR\         /# r  r   )r:   s   "r;   r<   r<   <  s      U r=   c                  ,    \         P                  ! 4       # r   )r]  rb  r9   r=   r;   nowre  <  s    r=   )get_hubis_module_patchedc                    V ^8  d   QhRR/# )r6   r8   zOptional[Hub]r9   )r:   s   "r;   r<   r<   F  s      O r=   c                      R # r   r9   r9   r=   r;   get_gevent_hubrk  F  s    r=   c                0    V ^8  d   QhR\         R\        /# )r6   mod_namer8   r  )r:   s   "r;   r<   r<   I  s      C D r=   c                     R # )Fr9   )rm  s   &r;   rh  rh  I  s    r=   c                $    V ^8  d   QhR\         /# r  r   )r:   s   "r;   r<   r<   N  s     J J4 Jr=   c                  >    \        R 4      ;'       g    \        R4      # )ro  _threadrg  r9   r=   r;   	is_geventrr  N  s    [)II->y-IIr=   c                     V ^8  d   QhRRRR/# )r6   r  zOptional[threading.Thread]r8   z#Tuple[Optional[int], Optional[str]]r9   )r:   s   "r;   r<   r<   R  s     1 1(1*1r=   c                   V e"    V P                   pV P                  pVe   W3#  \        4       '       d   \	        4       pVe    VP
                  R3#  \        P                  ! 4       p V P                   pV P                  pVe   W3#   \        P                  ! 4       p V P                   pV P                  pVe   W3#  R#   \         d     Li ; i  \         d     Li ; i  \         d     Lgi ; i  \         d     R# i ; i)zC
Try to get the id of the current thread, with various fall backs.
Nr  )	identr@  r   rr  rk  thread_identro  current_threadmain_thread)r  	thread_idthread_name
gevent_hubs   &   r;   get_current_thread_metar|  R  s2    	I ++K$ -- % {{#%
!!..44
))+LL	kk )) !&&(LL	kk )) ! G  		 "      	sG   C C 3C# 
3C4 CCC C #C10C14DDc                ,    V ^8  d   QhRRRRR\         /# )r6   r   r   r7   r8   r   )r:   s   "r;   r<   r<     s!      5  4 r=   c                 f    V \         8X  d&   \        VR 4      '       d   VP                  R9   d   R# R# )codeFT)r   N)
SystemExitrw  r  )r   r7   s   &&r;   should_be_treated_as_errorr    s'    	ZGE622uzzY7Nr=   Tc                $    V ^8  d   QhRRRRRR/# )r6   convert_funczCallable[[Any], T]r7   r   r8   zOptional[T]r9   )r:   s   "r;   r<   r<     s"      2 5 ] r=   c                     \        W4      '       d   V#   V ! V4      #   \         d     Li ; i  \         d     R# i ; i)z
Attempt to convert from an unknown type to a specific type, using the
given function. Return None if the conversion fails, i.e. if the function
raises an exception.
N)r   r  rc  )r  r7   s   &&r;   try_convertr    sS    e**L +
E""	  
  s    0 --??c                (    V ^8  d   QhRRR\         /# rG   r   )r:   s   "r;   r<   r<     s     + + +3 +r=   c                   a R V3R llo S! V 4      p\         P                  ! V\        R7      #   \         d    \        T 4      u # i ; i)z&Safely serialize to a readable string.c                     V ^8  d   QhRRRR/# )r6   rD  r   r8   z6Union[str, dict[Any, Any], list[Any], tuple[Any, ...]]r9   )r:   s   "r;   r<   $safe_serialize.<locals>.__annotate__  s     " ""	A"r=   c                 x  < \        V 4      '       da    \        V R R4      p\        V RR4      p\        V RR4      pV'       d   V'       d	   V RV 2pMV'       d   V'       d	   V RV 2pMTpRV R2# \        V \        4      '       d,   V P                  4        UUu/ uF  w  rVVS	! V4      bK  	  upp# \        V \        \        34      '       d   V  Uu. uF  pS	! V4      NK  	  up# \        V R	4      '       dj    \        V 4      P                  4        UUu/ uF'  w  rVVP                  R
4      '       d   K  VS	! V4      bK)  	  pppR\        V 4      P                   RV R2# V #   \         d    R\        T 4      P                   R2u # i ; iu uppi u upi u uppi   \         d    \        T 4      u # i ; i)r   Nr   r   	anonymousr   z
<function >z
<callable r  r  < )callablerR  rc  r7  r   r   r   rA  r  r3  rw  r  r`  r  )
rD  rr  qualnamer@  	full_pathkr6  r\  attrsserialize_items
   &        r;   r  &safe_serialize.<locals>.serialize_item  s    D>>; |T:"4>tZ=h#)(!H: 6I#)(!D6 2I $I#I;a00 d##59ZZ\B\TQA~a((\BBtUm,,/34t!N1%t44T:&&" !%T
 0 0 2 2<<, )A~a(( 2  
 4:../qq99 K#  ;#DJ$7$7#8::; C4  "Dz!"sY   6E% E% E% #E% FF;F  F7FF  %$FFF   F98F9)r  )rP   rQ   r?   rc  )rH   
serializedr  s   & @r;   safe_serializer    sG    " "H#D)
zz*c22 4ys   #0 A	A	c                (    V ^8  d   QhRRR\         /# r6   r  Optional[dict[str, Any]]r8   r   )r:   s   "r;   r<   r<     s      8 T r=   c                     V f   R# \        V P                  RR4      ;'       g    V R,          P                  RR4      4      # )NFenable_logs_experimentsrC   r   r  s   &r;   has_logs_enabledr    sD    M5) 	= 	=>"&&}e< r=   c                     V ^8  d   QhRRRR/# )r6   r  r  r8   z.Optional[Callable[[Log, Hint], Optional[Log]]]r9   )r:   s   "r;   r<   r<     s      '5r=   c                 p    V f   R # V P                  R4      ;'       g    V R,          P                  R4      # )Nbefore_send_logr  r   r  s   &r;   get_before_send_logr    s=     ;;()  W^-D-H-H. r=   c                (    V ^8  d   QhRRR\         /# r  r   )r:   s   "r;   r<   r<     s     5 5!; 5 5r=   c                 D    V f   R# \        V P                  RR4      4      # )NFenable_metricsTr  r  s   &r;   has_metrics_enabledr    s!    ,d344r=   c                     V ^8  d   QhRRRR/# )r6   r  r  r8   z4Optional[Callable[[Metric, Hint], Optional[Metric]]]r9   )r:   s   "r;   r<   r<     s      ';r=   c                 p    V f   R # V P                  R4      ;'       g    V R,          P                  R4      # )Nbefore_send_metricr  r  r  s   &r;   get_before_send_metricr    s=     ;;+,  0G0K0K1 r=   )falser  nnooff0)truetyyeson1)+r+  r   )NNN)NTTNN)TTN)NNNNNN)NNr   r   NNr  )r  r  rb   r  r  )TTFr  )T)NF)r  rP   rz  loggingr  ra   r  r,  rf   rd   ro  r]  collectionsr   r   r   decimalr   	functoolsr   r   r	   numbersr
   urllib.parser   r   r   r   r   rV  r   rx  typingr   r   sentry_sdk._compatr   sentry_sdk._typesr   r   r   sentry_sdk.constsr   r   r   r   typesr   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   
gevent.hubr,   r-   r.   r/   r0   r1   r2   r3   r   	getLoggerr   r0  r-  r  	frozensetrA   rB   r  rE   rS   rt   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r"  rS  rY  re  rk  r  r  r  r  r  r  r  r  r  r  rw  rc  HAS_CHAINED_EXCEPTIONSr  r  r  r  r  r  r'  r&  r   r  r>  r+  r,  r-  rT  rX  r  rk  r  r  r  HAS_REAL_CONTEXTVARSrr  CONTEXTVARS_ERROR_MESSAGEr  r  r  r  r  r  r  r  r  r  r  r  r
  r  r  r$  r  r-  r1  r8  r  rA  rH  r_  re  rw  rf  rk  rx  rh  rr  r|  r  r  r  r  r  r  r  r  r9   r=   r;   <module>r     s        	  	  
   " '  3 3  K K+
 !  # R R  .    & CC#AA 	q! 
		.	/ **12BC BC  +E +T
60 F $ 78 'H+	5 j) +*
""Z "L
 L
^+R +R\P$*Z6 20f4-$cL !,BC 7>c&L(V!
.((V8(V:
<0f0f8"7J $4#5   j (V( ##:; 	y 	B
I$$ B
J * &WX
-&` {$@A	6<&	A8(
" 	
 ; ;
 A A EK*Z &
.0/J1h A$+\5o>  X9  s$   $O7 !P 7	PPPP