+
    Ni3                       a  R t00 t ^ RIt^ RI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Ht ^ RIHt ]'       dr   ^ RIHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ]]]3,          t]]]]]3,          .]]]3,          3,          t]]] 3,          t!]]"]#]$3t%Rt&^t'^
t(Rt). t*] ^ k R R lt+]].t,] ^k R R lt- ! R R4      t.R R lt/R# )    N)MappingSequenceSet)datetime)AnnotatedValuecapture_internal_exceptiondisable_capture_eventformat_timestamp	safe_reprstrip_string)TYPE_CHECKING)TracebackType)Any)Callable)ContextManager)Dict)List)Optional)Type)Union)NotImplementedTypez<cyclic>c                     V ^8  d   QhRRRR/# )   	processorReprProcessorreturnN )formats   "</tmp/pip-target-e6j6ikcs/lib/python/sentry_sdk/serializer.py__annotate__r    =   s     - - -T -    c                 0    \         P                  V 4       R # N)global_repr_processorsappend)r   s   &r   add_global_repr_processorr&   =   s    !!),r!   c                (    V ^8  d   QhR\         RR/# )r   tyr   N)type)r   s   "r   r    r    D   s      t  r!   c                 0    \         P                  V 4       R # r#   )sequence_typesr%   )r(   s   &r   add_repr_sequence_typer,   D   s    "r!   c                   l   a  ] tR t^Ht o R	tV 3R lR 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
# )Memoc                   < V ^8  d   QhRR/# )r   r   Nr   )r   __classdict__s   "r   r    Memo.__annotate__K   s     % %$ %r!   c                "    / V n         . V n        R # r#   _ids_objs)selfs   &r   __init__Memo.__init__K   s    &(	"$
r!   c                "   < V ^8  d   QhRRRR/# )r   objr   r   zContextManager[bool]r   )r   r0   s   "r   r    r1   O   s      5 %; r!   c                <    V P                   P                  V4       V # r#   )r5   r%   r6   r:   s   &&r   memoizeMemo.memoizeO   s    

#r!   c                    < V ^8  d   QhRS[ /# )r   r   )bool)r   r0   s   "r   r    r1   S   s      4 r!   c                    V P                   R,          p\        V4      V P                  9   d   R# WP                  \        V4      &   R# )   TF)r5   idr4   r<   s   & r   	__enter__Memo.__enter__S   s5    jjnc7dii!$IIbgr!   c                *   < V ^8  d   QhRRRRRRRR/# )	r   r(   zOptional[Type[BaseException]]valuezOptional[BaseException]tbzOptional[TracebackType]r   Nr   )r   r0   s   "r   r    r1   [   s3     2 2+2 )2 &	2
 
2r!   c                    V P                   P                  \        V P                  P                  4       4      R 4       R # r#   )r4   poprD   r5   )r6   r(   rH   rI   s   &&&&r   __exit__Memo.__exit__[   s&     			b)*D1r!   r3   N)__name__
__module____qualname____firstlineno__	__slots__r7   r=   rE   rL   __static_attributes____classdictcell__)r0   s   @r   r.   r.   H   s2     !I% %  2 2r!   r.   c                $    V ^8  d   QhRRRRRR/# )r   eventzDict[str, Any]kwargsr   r   r   )r   s   "r   r    r    d   s(     b) b)% b) b);K b)r!   c                  aaaaaaa	a
aaaaaaa \        4       o. o. oVP                  RR4      R8H  oVP                  RR4      oVP                  RR4      oVP                  RR4      oR V3R	 lloR
 VV3R lloR VVV3R lloR V3R lloR V3R lloRR V
VVV3R lllo	R V3R lloR VVVVVVV	VVVVV3R llo
\        P                  ! R4        S	! V 3/ VB pS'       g+   S'       d#   \	        V\
        4      '       d   S^ ,          VR&   V\        P                  ! R4       #   \        P                  ! R4       i ; i)a<  
A very smart serializer that takes a dict and emits a json-friendly dict.
Currently used for serializing the final Event and also prematurely while fetching the stack
local variables for each frame in a stacktrace.

It works internally with 'databags' which are arbitrary data structures like Mapping, Sequence and Set.
The algorithm itself is a recursive graph walk down the data structures it encounters.

It has the following responsibilities:
* Trimming databags and keeping them within MAX_DATABAG_BREADTH and MAX_DATABAG_DEPTH.
* Calling safe_repr() on objects appropriately to keep them informative and readable in the final payload.
* Annotating the payload with the _meta field whenever trimming happens.

:param max_request_body_size: If set to "always", will never trim request bodies.
:param max_value_length: The max length to strip strings to, defaults to sentry_sdk.consts.DEFAULT_MAX_VALUE_LENGTH
:param is_vars: If we're serializing vars early, we want to repr() things that are JSON-serializable to make their type more apparent. For example, it's useful to see the difference between a unicode-string and a bytestring when viewing a stacktrace.
:param custom_repr: A custom repr function that runs before safe_repr on the object to be serialized. If it returns None or throws internally, we will fallback to safe_repr.

max_request_body_sizeNalwaysmax_value_lengthis_varsFcustom_reprc                (    V ^8  d   QhRRR\         /# )r   rH   r   r   )str)r   s   "r   r    serialize.<locals>.__annotate__   s     $ $% $C $r!   c                    <  R pSe	   S! V 4      pT;'       g    \        V 4      #   \         d    \        T 4      u # i ; ir#   )r   	Exception)rH   
repr_valuer]   s   & r   _safe_repr_wrapper%serialize.<locals>._safe_repr_wrapper   sJ    	$J&(/
115!11 	$U##	$s   & & ??c                     V ^8  d   QhRRRR/# )r   metar   r   Nr   )r   s   "r   r    r`      s     
7 
7% 
7D 
7r!   c                  N  < \        S4      \        S4      8:  dP    S\        S4      ^,
          ,          pSR,          P                  \        V4      / 4      pSP	                  V4       Kh  SR,          P                  R/ 4      P                  V 4       R#   \         d    / p LLi ; i)rB    NrC   )len
setdefaultr_   
IndexErrorr%   update)rg   segmentnode
meta_stackpaths   ,  r   	_annotateserialize.<locals>._annotate   s    *oT*s:23!"~00WrB d#2!!"b)006  s   ;B B$#B$c                    V ^8  d   QhRR/# r   r   Optional[bool]r   )r   s   "r   r    r`      s      ) r!   c                    <  S'       d   R# S! 4       p V R9   d   V # S^ ,          pVR8X  d   S^,          R8X  d   S^,           R# VR8X  d   R#  R#   \          d     R# i ; i)z
A databag is any value that we need to trim.
True for stuff like vars, request bodies, breadcrumbs and extra.

:returns: `True` for "yes", `False` for :"no", `None` for "maybe soon".
TNbreadcrumbsvaluesextraF)TNrl   )is_request_bodyp0_is_request_bodyr\   rq   s     r   _is_databagserialize.<locals>._is_databag   sr    	.0O,.&&aB]"tAw(':QW}    		s!   A A 'A A A! A!c                    V ^8  d   QhRR/# ru   r   )r   s   "r   r    r`      s       0 r!   c                  j   <  S ^ ,          R8X  d   S ^,          R8X  d   R# R#   \          d     R# i ; i)r   spansdataTNFr{   rq   s   r   _is_span_attribute%serialize.<locals>._is_span_attribute   s;    	Aw'!d1g&7   		   # # 22c                    V ^8  d   QhRR/# ru   r   )r   s   "r   r    r`      s      . r!   c                  j   <  S ^ ,          R8X  d   S ^,          R8X  d   R# R#   \          d     R# i ; i)r   requestr   TNFr{   r   s   r   r~   #serialize.<locals>._is_request_body   s;    	Aw)#Q6(9   		r   c                8    V ^8  d   QhRRRRRRRRRRR	R
RR
RR/# )r   r:   r   
is_databagrv   r|   should_repr_stringsrn   zOptional[Segment]remaining_breadthzOptional[Union[int, float]]remaining_depthr   r   )r   s   "r   r    r`      sX     #0 #0#0$#0 *#0 .	#0
 %#0 9#0 7#0 
#0r!   c                 n  < Ve   SP                  V4        S	P                  V 4      ;_uu_ 4       pV'       d;   \        uuR R R 4       Ve'   SP                  4        S
\	        S4      ^,           R 1 # # S! V VVVVVR7      uuR R R 4       Ve'   SP                  4        S
\	        S4      ^,           R 1 # #   + '       g   i     M; i  \
         d    \        \        P                  ! 4       4       T'       d/    Te(   SP                  4        S
\	        S4      ^,           R 1 R# R#  Te(   SP                  4        S
\	        S4      ^,           R 1 R # R # i ; i Te(   SP                  4        S
\	        S4      ^,           R 1 R # R #   Te'   SP                  4        S
\	        S4      ^,           R 1 i i ; i)N)r   r|   r   r   r   z=<failed to serialize, use init(debug=True) to see error logs>)	r%   r=   CYCLE_MARKERrK   rj   BaseExceptionr   sysexc_info)r:   r   r|   r   rn   r   r   result_serialize_node_implmemorp   rq   s   &&&&&&& r   _serialize_node"serialize.<locals>._serialize_node   s    KK 	0c""f' #"( "
s4y1}/ #! ,)$3(;$3&7	 #"( "
s4y1}/ #) #"  	&s||~6V "
s4y1}/ # "
s4y1}/ #	 #( "
s4y1}/ #w"
s4y1}/ #sW   C	 B6
C	 4B6
C	 6C	C	 F C	 	1E:F (F EF ,F4c                     V ^8  d   QhRRRR/# )r   r:   r   r   r   )r   s   "r   r    r`      s       % r!   c                 p   < \        V \        4      '       d   S! R/ V P                  B  V P                  p V # )Nr   )
isinstancer   metadatarH   )r:   rr   s   &r   _flatten_annotated%serialize.<locals>._flatten_annotated   s-    c>**%%))C
r!   c                4    V ^8  d   QhRRRRRRRRRRR	RR
R/# )r   r:   r   r   rv   r|   r   r   zOptional[Union[float, int]]r   r   r   )r   s   "r   r    r`      s`     JR JRJR$JR *JR .	JR
 7JR 9JR 
JRr!   c                   < \        V \        4      '       d   R pVf   SpVf   S! 4       pVf   S! 4       pV'       d<   V'       d    S'       d   \        R4      p\        R4      pMVf   \        pVf   \        pS! V 4      p Ve7   V^ 8:  d0   S! RR..R7       V'       d   S! \        S! V 4      SR7      4      # R# S! 4       pV'       g	   V'       d<   \        '       d0   RSRV/p\         F  pV! W4      p	V	\        Jg   K  S! V	4      u # 	  \        \        V 4      R	R4      p
V e"   \        V \        \        \        34      '       da   V'       gO   \        V \        4      '       dA   \        P                  ! V 4      '       g   \        P                  ! V 4      '       d	   S! V 4      # V # \        V
4      '       d	   V
! V 4      # \        V \         4      '       d%   V'       g   \#        \%        V 4      4      # S! V 4      # \        V \&        4      '       d   \)        V P+                  4       4      p / p^ pV P+                  4        FX  w  rVe   W8  d   S! \-        V 4      R
7        V# \#        V4      pS! TTTTTVe
   V^,
          MRVR7      pWV&   V^,          pKZ  	  V# \        V \.        4      '       g   \        V \1        \2        4      4      '       dc   . p\5        V 4       FO  w  rVe   W8  d   S! \-        V 4      R
7        V# TP7                  S! TTTTTVe
   V^,
          MRVR7      4       KQ  	  V# V'       d
   S! V 4      p M\\        V \8        4      '       g   \        V \:        4      '       d   V P=                  RR4      p \        V \"        4      '       g	   S! V 4      p \-        S4      ^8H  ;'       d!    S^ ,          R8H  ;'       d    SR,          R8H  pV'       d   V # S! \        V SR7      4      # )FNinfz!limitx)rem)
max_lengthr   r   __sentry_repr__)rj   )rn   r   r   r|   r   r   zutf-8replacer   descriptionrC   )r   r   floatMAX_DATABAG_DEPTHMAX_DATABAG_BREADTHr   r$   NotImplementedgetattrr)   r@   intmathisinfisnancallabler   r_   r
   r   dictitemsrj   serializable_str_typestupler+   	enumerater%   bytes	bytearraydecode)r:   r   r|   r   r   r   is_span_attributehintsr   r   sentry_reprrv_dictikvstr_krv_listis_span_descriptionrr   r   r   r~   r   rd   r   r\   keep_request_bodiesr[   r   rq   s   &&&&&&            r   r   'serialize.<locals>._serialize_node_impl   s    c>**"'&")$J".0O#6"',$)%L!"*&7O$,(;% %&?a+?Hc?+,) !3C!8EUV  .0+1G1GT#4oFE3	"3./-f55 4
 d3i):DA;*S4e*<=="3&&DJJsOOtzz#)#..
k""s##X&& + $S)* (, W%% syy{#C(*GA		$0Q5K#c(+" N A#!(;)$3/>/J!+PT&7
 "#Q% $( NC!788Z~&>
 >
 G!#$0Q5K#c(+  N # !,?#-(73B3NOa/TX*;
 '& N$S)C#u%%C)C)Cjj)4c3''(- INOOtAw'1OOd2h-6O 	 J!,s?O"PQQr!   T_meta)NNNNNN)r.   rK   r	   setr   r   )rV   rW   serialized_eventrr   r   r   r~   r   rd   r   r   r]   r\   r   r[   r   rp   rq   s   &, @@@@@@@@@@@@@@@r   	serializer   d   s$   ( 6DD)+J &

+BD IX U(.

3Et(LjjE*G28**]D2QK$ $
7 
7 8  #0 #0J JR JR JR^ d#)*5;F;:*5Et*L*L(21W%!!%(!!%(s   D. ,D. 4#D. .Ec                X    V ^8  d   Qh/ ^ \         9   d   R;R&   ^\         9   d   R;R&   # )r   zList[ReprProcessor]r$   z
List[type]r+   __conditional_annotations__)r   s   "r   r    r       s/    

r 3 2- 2s @ / . .A r!   i@B )1r   r   r   collections.abcr   r   r   r   sentry_sdk.utilsr   r   r	   r
   r   r   typingr   typesr   r   r   r   r   r   r   r   r   sentry_sdk._typesr   r_   Spanr   r   Segmentr   r   
memoryviewr   MAX_EVENT_BYTESr   r   r   r$   r&   r+   r,   r.   r   r    r   s   @r   <module>r      s    

  2 2   !#%4S>Dc4S>2E:Lc:Q4RRSMCHoG ui<      13  2- !)# .2 28b)r!   