Ë
    ëÏjÆ@  ã                  óâ  — U d Z ddlmZ ddlZddlZddlZddlmZmZ ddl	m
Z
mZmZ ddlmZ ddlmZmZ ddlmZmZ 	 ddlZddlZd	d
lmZ g d¢ZdZdZdZdZeed   z  Zde d<   e G d„ d«      «       Z!e G d„ d«      «       Z"e G d„ d«      «       Z#e G d„ d«      «       Z$d"d„Z%	 	 	 d#	 	 	 	 	 	 	 	 	 d$d„Z&deedddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d%d„Z' G d „ d!«      Z(y# e$ r dZY Œ¦w xY w)&z÷
Extract a structured traceback from an exception.

Based on work by Will McGugan
<https://github.com/hynek/structlog/pull/407#issuecomment-1150926246>`_ from
`rich.traceback
<https://github.com/Textualize/rich/blob/972dedff/rich/traceback.py>`_.
é    )ÚannotationsN)ÚIterableÚSequence)ÚasdictÚ	dataclassÚfield)Úwalk_tb)Ú
ModuleTypeÚTracebackType)ÚAnyÚ	TypeAliasé   )ÚExcInfo)ÚExceptionDictTransformerÚFrameÚStackÚSyntaxError_ÚTraceÚextractÚsafe_strÚto_reprTé
   éP   é2   )NNNr   Ú
OptExcInfoc                  ó>   — e Zd ZU dZded<   ded<   ded<   dZded	<   y)
r   z*
    Represents a single stack frame.
    ÚstrÚfilenameÚintÚlinenoÚnameNzdict[str, str] | NoneÚlocals)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r"   © ó    úQ/var/www/html/gaurav-v2/venv/lib/python3.12/site-packages/structlog/tracebacks.pyr   r   9   s#   … ñð ƒMØƒKØ
ƒIØ$(€FÐ!Ô(r)   r   c                  óD   — e Zd ZU dZded<   ded<   ded<   ded<   ded<   y	)
r   zL
    Contains detailed information about :exc:`SyntaxError` exceptions.
    r   Úoffsetr   r   Úliner    ÚmsgN©r#   r$   r%   r&   r'   r(   r)   r*   r   r   E   s"   … ñð ƒKØƒMØ
ƒIØƒKØ	„Hr)   r   c                  ó¤   — e Zd ZU dZded<   ded<    ee¬«      Zded<   dZd	ed
<   dZ	ded<    ee¬«      Z
ded<   dZded<    ee¬«      Zded<   y)r   zÖ
    Represents an exception and a list of stack frames.

    .. versionchanged:: 25.2.0
       Added the *exc_notes* field.

    .. versionchanged:: 25.4.0
       Added the *is_group* and *exceptions* fields.
    r   Úexc_typeÚ	exc_value)Údefault_factoryz	list[str]Ú	exc_notesNzSyntaxError_ | NoneÚsyntax_errorFÚboolÚis_causezlist[Frame]ÚframesÚis_groupzlist[Trace]Ú
exceptions)r#   r$   r%   r&   r'   r   Úlistr4   r5   r7   r8   r9   r:   r(   r)   r*   r   r   R   s_   … ñð ƒMØƒNÙ °Ô6€IˆyÓ6Ø(,€LÐ%Ó,Ø€HˆdÓÙ°Ô5€FˆKÓ5Ø€HˆdÓÙ#°DÔ9€J�Ô9r)   r   c                  ó   — e Zd ZU dZded<   y)r   z/
    Container for a list of stack traces.
    zlist[Stack]ÚstacksNr/   r(   r)   r*   r   r   h   s   … ñð Ôr)   r   c                ód   — 	 t        | «      S # t        $ r}dt        |«      ›d�cY d}~S d}~ww xY w)z1Don't allow exceptions from __str__ to propagate.z<str-error Ú>N)r   Ú	Exception)Ú_objectÚerrors     r*   r   r   q   s4   € ð-Ü�7‹|ÐøÜò -ØœS ›Z˜N¨!Ð,Õ,ûð-ús   ‚
 �	/–*¤/ª/c                óÊ  — |r8t         �2t         j                  j                  | ||¬«      j                  «       }|S 	 t	        | t
        t        f«      r8|�(t        | «      |kD  rt        | «      |z
  }| d| ›d|› �}|S t        | «      }	 |S t        | «      }|�&t        |«      |kD  rt        |«      |z
  }|d| ›d|› �}|S # t        $ r}dt        |«      ›d�}Y d}~|S d}~ww xY w)aá  
    Get repr string for an object, but catch errors.

    :func:`repr()` is used for strings, too, so that secret wrappers that
    inherit from :func:`str` and overwrite ``__repr__()`` are handled correctly
    (i.e. secrets are not logged in plain text).

    Args:
        obj: Object to get a string representation for.

        max_length: Maximum length of containers before abbreviating, or
            ``None`` for no abbreviation.

        max_string: Maximum length of string before truncating, or ``None`` to
            disable truncating.

        use_rich: If ``True`` (the default), use rich_ to compute the repr.
            If ``False`` or if rich_ is not installed, fall back to a simpler
            algorithm.

    Returns:
        The string representation of *obj*.

    .. versionchanged:: 24.3.0
       Added *max_length* argument.  Use :program:`rich` to render locals if it
       is available.  Call :func:`repr()` on strings in fallback
       implementation.
    N)Ú
max_lengthÚ
max_stringÚ+z<repr-error r?   )
ÚrichÚprettyÚtraverseÚrenderÚ
isinstancer   ÚbytesÚlenÚreprr@   )ÚobjrD   rE   Úuse_richÚobj_reprÚ	truncatedrB   s          r*   r   r   y   s  € ñD ”DÐ$ô —;‘;×'Ñ'Ø˜J°:ð (ó 
ç
‰&‹(ð 	ð, €Oð	6Ü˜#¤¤U˜|Ô,ØÐ)¬c°#«h¸Ò.CÜ # C£¨:Ñ 5�IØ"% k zÐ"2Ð!5°Q°y°kÐB�Hð €Oô  $ C›y‘Hð €Oô   ›9�ØÐ)¬c°(«m¸jÒ.HÜ # H£°
Ñ :�IØ"*¨;¨JÐ"7Ð!:¸!¸I¸;ÐG�Hð €Oøô ò 	6Ø%¤c¨%£j ^°1Ð5ŒHà€Oûð	6ús#   ¼>B? Á<B? Â
3B? Â?	C"ÃCÃC"F©Úshow_localsÚlocals_max_lengthÚlocals_max_stringÚlocals_hide_dunderÚlocals_hide_sunderrP   Ú_seenc               ó  ‡‡— g }
d}|	€
t        «       }		 t        |«      }||	v r�nÅ|	j                  |«       t        t	        | j
                  «      t	        |«      t        |dd«      D �cg c]  }t	        |«      ‘Œ c}|¬«      }t        j                  dk\  rot        |t        t        f«      rYd|_        |j                  D ]C  }|j                  j                  t        t!        |«      ||j"                  |||‰‰||	¬«
      «       ŒE t        |t$        «      rWt'        |j(                  xs d	|j*                  xs d
|j,                  xs d	|j.                  xs d|j0                  ¬«      |_        |
j                  |«       |j4                  j                  }	 	 	 	 dˆˆfd„}t7        |«      D ]¿  \  }}|j8                  j:                  }|r0|j=                  d«      st>        j@                  jC                  |«      }tE        |xs d
||j8                  jF                  |rA ||jH                  jK                  «       «      D ��ci c]  \  }}|tM        ||||¬«      “Œ c}}nd¬«      } ||«       ŒÁ t        |dd«      }|r*|j"                  r|jN                  } |}|j"                  }d}�Œ‘|jP                  }|r7|j"                  r+t        |dd«      s|jN                  } |}|j"                  }d}�ŒÖ	 tS        |
¬«      S c c}w c c}}w )aa  
    Extract traceback information.

    Args:
        exc_type: Exception type.

        exc_value: Exception value.

        traceback: Python Traceback object.

        show_locals: Enable display of local variables. Defaults to False.

        locals_max_length:
            Maximum length of containers before abbreviating, or ``None`` for
            no abbreviation.

        locals_max_string:
            Maximum length of string before truncating, or ``None`` to disable
            truncating.

        locals_hide_dunder:
            Hide locals prefixed with double underscore.
            Defaults to True.

        locals_hide_sunder:
            Hide locals prefixed with single underscore.
            This implies hiding *locals_hide_dunder*.
            Defaults to False.

        use_rich: If ``True`` (the default), use rich_ to compute the repr.
            If ``False`` or if rich_ is not installed, fall back to a simpler
            algorithm.

    Returns:
        A Trace instance with structured information about all exceptions.

    .. versionadded:: 22.1.0

    .. versionchanged:: 24.3.0
       Added *locals_max_length*, *locals_hide_sunder*, *locals_hide_dunder*
       and *use_rich* arguments.

    .. versionchanged:: 25.4.0
       Handle exception groups.

    .. versionchanged:: 25.5.0
       Handle loops in exception cause chain.
    FNTÚ	__notes__r(   )r1   r2   r4   r7   )é   é   rS   r   Ú?Ú )r,   r   r    r-   r.   c              3  ó    •K  — ‰s‰s| E d{  –—†  y| D ]3  \  }}‰r|j                  d«      rŒ‰r|j                  d«      rŒ.||f–— Œ5 y7 Œ>­w)z-Extract locals from an iterator of key pairs.NÚ__Ú_©Ú
startswith)Úiter_localsÚkeyÚvaluerW   rX   s      €€r*   Ú
get_localszextract.<locals>.get_locals)  sZ   øè ø€ ñ 'Ñ*<Ø&×&Ð&ØÛ)‘
��UÙ%¨#¯.©.¸Ô*>ØÙ%¨#¯.©.¸Ô*=ØØ˜5�jÓ ñ *ð 'ús   ƒ
A�AŽ?AÚ<)rD   rE   rP   )r   r    r!   r"   Ú	__cause__Ú__suppress_context__)r=   )re   úIterable[tuple[str, object]]Úreturnrl   )*ÚsetÚidÚaddr   r   r#   ÚgetattrÚsysÚversion_inforK   ÚBaseExceptionGroupÚExceptionGroupr9   r:   Úappendr   ÚtypeÚ__traceback__ÚSyntaxErrorr   r,   r   r    Útextr.   r5   r8   r	   Úf_codeÚco_filenamerd   ÚosÚpathÚabspathr   Úco_nameÚf_localsÚitemsr   Ú	__class__Ú__context__r   )r1   r2   Ú	tracebackrT   rU   rV   rW   rX   rP   rY   r=   r7   Úexc_idÚnoteÚstackÚ	exceptionrv   rh   Úframe_summaryÚline_nor   rf   rg   ÚframeÚcauses         ``                 r*   r   r   ·   sý  ù€ ð| €FØ€Hà€}Ü“ˆà
Ü�I“ˆØ�U‰?ÙØ�	‰	�&ÔäÜ˜h×/Ñ/Ó0Ü˜yÓ)ä+2°9¸kÈ2Ô+NóÙ+N 4”˜•Ð+Nñð ô
ˆô ×Ñ˜wÒ&Ü˜)Ô&8¼.Ð%IÔJØ!%�”Ø!*×!5Ô!5�IØ×$Ñ$×+Ñ+ÜÜ  ›OØ%Ø%×3Ñ3Ø(3Ø.?Ø.?Ø/AØ/AØ%-Ø"'ôõð "6ô  �i¤Ô-Ü!-Ø ×'Ñ'Ò,¨1Ø"×+Ñ+Ò2¨sØ ×'Ñ'Ò,¨1Ø—^‘^Ò) rØ—M‘Mô"ˆEÔð 	�‰�eÔØ—‘×$Ñ$ˆð	!Ø5ð	!à)ö	!ô '.¨iÖ&8Ñ"ˆM˜7Ø$×+Ñ+×7Ñ7ˆHÙ × 3Ñ 3°CÔ 8ÜŸ7™7Ÿ?™?¨8Ó4�ô
 Ø!š SØØ"×)Ñ)×1Ñ1ñ #ñ	 +5Ø)×2Ñ2×8Ñ8Ó:ô+ô
ñ+™J˜C ð œWØ!Ø'8Ø'8Ø%-ô	ñ ð+ó
ð ô#ˆEñ( �5�Mð9 '9ô< ˜	 ;°Ó5ˆÙ�U×(Ò(Ø—‘ˆHØˆIØ×+Ñ+ˆIØˆHÙà×%Ñ%ˆáØ×#Ò#Ü˜IÐ'=¸uÔEà—‘ˆHØˆIØ×+Ñ+ˆIØˆHÙð 	ä˜ÔÐùòQùó@
s   Á(K6È<K;c            	      ó^   — e Zd ZdZeeedddeddœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d
d„Zdd„Z	dd„Z
y	)r   a,  
    Return a list of exception stack dictionaries for an exception.

    These dictionaries are based on :class:`Stack` instances generated by
    :func:`extract()` and can be dumped to JSON.

    Args:
        show_locals:
            Whether or not to include the values of a stack frame's local
            variables.

        locals_max_length:
            Maximum length of containers before abbreviating, or ``None`` for
            no abbreviation.

        locals_max_string:
            Maximum length of string before truncating, or ``None`` to disable
            truncating.

        locals_hide_dunder:
            Hide locals prefixed with double underscore.
            Defaults to True.

        locals_hide_sunder:
            Hide locals prefixed with single underscore.
            This implies hiding *locals_hide_dunder*.
            Defaults to False.

        suppress:
            Optional sequence of modules or paths for which to suppress the
            display of locals even if *show_locals* is ``True``.

        max_frames:
            Maximum number of frames in each stack.  Frames are removed from
            the inside out.  The idea is, that the first frames represent your
            code responsible for the exception and last frames the code where
            the exception actually happened.  With larger web frameworks, this
            does not always work, so you should stick with the default.

        use_rich: If ``True`` (the default), use rich_ to compute the repr of
            locals.  If ``False`` or if rich_ is not installed, fall back to
            a simpler algorithm.

    .. seealso::
        :doc:`exceptions` for a broader explanation of *structlog*'s exception
        features.

    .. versionchanged:: 24.3.0
       Added *locals_max_length*, *locals_hide_sunder*, *locals_hide_dunder*,
       *suppress* and *use_rich* arguments.

    .. versionchanged:: 25.1.0
       *locals_max_length* and *locals_max_string* may be None to disable
       truncation.

    .. versionchanged:: 25.4.0
       Handle exception groups.
    TFr(   )rT   rU   rV   rW   rX   ÚsuppressÚ
max_framesrP   c               óh  — |�|dk  rd|› �}	t        |	«      ‚|�|dk  rd|› �}	t        |	«      ‚|dk  rd|› �}	t        |	«      ‚|| _        || _        || _        || _        || _        g | _        |D ]²  }
t        |
t        «      sG|
j                  €d|
›d�}	t        |	«      ‚t        j                  j                  |
j                  «      }n|
}t        j                  j                  t        j                  j                  |«      «      }| j                  j                  |«       Œ´ || _        || _        y )Nr   z""locals_max_length" must be >= 0: z""locals_max_string" must be >= 0: é   z"max_frames" must be >= 2: z"suppress" item z+ must be a module with '__file__' attribute)Ú
ValueErrorrT   rU   rV   rW   rX   r�   rK   r   Ú__file__r}   r~   ÚdirnameÚnormpathr   rv   r�   rP   )ÚselfrT   rU   rV   rW   rX   r�   r�   rP   r.   Úsuppress_entityr~   s               r*   Ú__init__z!ExceptionDictTransformer.__init__«  s?  € ð Ð(Ð->ÀÒ-BØ6Ð7HÐ6IÐJˆCÜ˜S“/Ð!ØÐ(Ð->ÀÒ-BØ6Ð7HÐ6IÐJˆCÜ˜S“/Ð!Ø˜Š>Ø/°
¨|Ð<ˆCÜ˜S“/Ð!Ø&ˆÔØ!2ˆÔØ!2ˆÔØ"4ˆÔØ"4ˆÔØ')ˆŒÛ'ˆOÜ˜o¬sÔ3Ø"×+Ñ+Ð3à*¨?Ð*=ð >;ð <ð ô % S›/Ð)Ü—w‘w—‘ ×'?Ñ'?Ó@‘à&�Ü—7‘7×#Ñ#¤B§G¡G§O¡O°DÓ$9Ó:ˆDØ�M‰M× Ñ  Õ&ð  (ð %ˆŒØ ˆ�r)   c           
     óö  — t        || j                  | j                  | j                  | j                  | j
                  | j                  dœŽ}|j                  D ]Ž  }t        |j                  «      | j                  k  rŒ&| j                  dz  }t        dddt        |j                  «      d|z  z
  › �¬«      }g |j                  d | ¢|‘|j                  | d  ¢|j                  d d  Œ� | j                  |«      S )N)rT   rU   rV   rW   rX   rP   r’   r_   éÿÿÿÿzSkipped frames: )r   r    r!   )r   rT   rU   rV   rW   rX   rP   r=   rM   r8   r�   r   Ú_as_dict)r—   Úexc_infoÚtracerˆ   ÚhalfÚ
fake_frames         r*   Ú__call__z!ExceptionDictTransformer.__call__Ö  sÿ   € ÜØØ×(Ñ(Ø"×4Ñ4Ø"×4Ñ4Ø#×6Ñ6Ø#×6Ñ6Ø—]‘]ò
ˆð —\”\ˆEÜ�5—<‘<Ó  D§O¡OÒ3Øð —‘ 1Ñ$ð ô ØØØ'¬¨E¯L©LÓ(9¸QÀ¹XÑ(FÐ'GÐHôˆJð
Ø—‘˜e˜tÐ$ðàðð —‘˜t˜e˜fÐ%ðˆE�L‰L™‰Oð "ð$ �}‰}˜UÓ#Ð#r)   c                óB  ‡— g }|j                   D ]‡  }t        |«      }|d   D ])  Š‰d   �t        ˆfd„| j                  D «       «      sŒ'‰d= Œ+ |j                  r,|j
                  D �cg c]  }| j                  |«      ‘Œ c}|d<   |j                  |«       Œ‰ |S c c}w )Nr8   r"   c              3  óF   •K  — | ]  }‰d    j                  |«      –— Œ y­w)r   Nrc   )Ú.0r~   Ú
frame_dicts     €r*   Ú	<genexpr>z4ExceptionDictTransformer._as_dict.<locals>.<genexpr>ú  s)   øè ø€ ð 7á -˜ð ˜zÑ*×5Ñ5°d×;Ù -ùs   ƒ!r:   )r=   r   Úanyr�   r9   r:   rœ   rv   )r—   rž   Ústack_dictsrˆ   Ú
stack_dictÚtr¥   s         @r*   rœ   z!ExceptionDictTransformer._as_dictõ  s¯   ø€ ØˆØ—\”\ˆEÜ ›ˆJØ(¨Ô2�
Ø˜hÑ'Ð/´3ó 7à $§¢ó7õ 4ð # 8Ñ,ð 3ð �~Š~à.3×.>Ò.>ó,Ù.>¨�D—M‘M !Õ$Ð.>ñ,�
˜<Ñ(ð ×Ñ˜zÕ*ð "ð Ðùò	,s   Á)BN)rT   r6   rU   r   rV   r   rW   r6   rX   r6   r�   zIterable[str | ModuleType]r�   r   rP   r6   rm   ÚNone)r�   r   rm   úlist[dict[str, Any]])rž   r   rm   r¬   )r#   r$   r%   r&   ÚSHOW_LOCALSÚLOCALS_MAX_LENGTHÚLOCALS_MAX_STRINGÚ
MAX_FRAMESr™   r¡   rœ   r(   r)   r*   r   r   o  sŒ   „ ñ9ð| (Ø!2Ø!2Ø#'Ø#(Ø/1Ø$Øñ)!ð ð)!ð ð	)!ð
 ð)!ð !ð)!ð !ð)!ð -ð)!ð ð)!ð ð)!ð 
ó)!óV$ô>r)   r   )rA   r   rm   r   )NNT)
rO   r   rD   ú
int | NonerE   r±   rP   r6   rm   r   )r1   ztype[BaseException]r2   ÚBaseExceptionr…   zTracebackType | NonerT   r6   rU   r   rV   r   rW   r6   rX   r6   rP   r6   rY   zset[int] | Nonerm   r   ))r&   Ú
__future__r   r}   Úos.pathrr   Úcollections.abcr   r   Údataclassesr   r   r   r…   r	   Útypesr
   r   Útypingr   r   rG   Úrich.prettyÚImportErrorr   Ú__all__r­   r®   r¯   r°   Útupler   r'   r   r   r   r   r   r   r   r   r(   r)   r*   Ú<module>r½      sÌ  ðòõ #ã 	Û Û 
ç .ß 0Ñ 0Ý ß +ß !ðÛÛõ ò	€ð €ØÐ ØÐ Ø€
à %Ð(8Ñ"9Ñ9€
ˆIÓ 9ð ÷)ð )ó ð)ð ÷	ð 	ó ð	ð ÷:ð :ó ð:ð* ÷ð ó ðó-ð "Ø!Øð	;Ø	ð;àð;ð ð;ð ð	;ð
 	ó;ðF Ø.Ø.Ø#Ø$ØØ!ñu Ø!ðu àðu ð $ðu ð
 ðu ð ðu ð ðu ð ðu ð ðu ð ðu ð ðu ð óu ÷pUò Uøða
 ò Ø‚Dðús   ¿C$ Ã$C.Ã-C.