+
    LV-j‡+  ã            
       ó´  € R t . RO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t]P                  RRRRRRR	R
/4      t ! R R]P"                  4      t ! R R]P&                  4      t]P*                  ! R4      tR]n        ]! ]4      t]P2                  ! 4       t]P7                  ]4       RRR/R R lllt ! R R]P:                  4      tR# )uo  
Logging utilities for dill.

The 'logger' object is dill's top-level logger.

The 'adapter' object wraps the logger and implements a 'trace()' method that
generates a detailed tree-style trace for the pickling call at log level INFO.

The 'trace()' function sets and resets dill's logger log level, enabling and
disabling the pickling trace.

The trace shows a tree structure depicting the depth of each object serialized
*with dill save functions*, but not the ones that use save functions from
'pickle._Pickler.dispatch'. If the information is available, it also displays
the size in bytes that the object contributed to the pickle stream (including
its child objects).  Sample trace output:

    >>> import dill, dill.tests
    >>> dill.detect.trace(True)
    >>> dill.dump_session(main=dill.tests)
    â”¬ M1: <module 'dill.tests' from '.../dill/tests/__init__.py'>
    â”œâ”¬ F2: <function _import_module at 0x7f0d2dce1b80>
    â”‚â”” # F2 [32 B]
    â”œâ”¬ D2: <dict object at 0x7f0d2e98a540>
    â”‚â”œâ”¬ T4: <class '_frozen_importlib.ModuleSpec'>
    â”‚â”‚â”” # T4 [35 B]
    â”‚â”œâ”¬ D2: <dict object at 0x7f0d2ef0e8c0>
    â”‚â”‚â”œâ”¬ T4: <class '_frozen_importlib_external.SourceFileLoader'>
    â”‚â”‚â”‚â”” # T4 [50 B]
    â”‚â”‚â”œâ”¬ D2: <dict object at 0x7f0d2e988a40>
    â”‚â”‚â”‚â”” # D2 [84 B]
    â”‚â”‚â”” # D2 [413 B]
    â”‚â”” # D2 [763 B]
    â”” # M1 [813 B]
N)Úpartial)ÚTextIOÚUnionõ   â”‚Ú|u   â”œõ   â”¬Ú+õ   â””Ú`c                   óH   a € ] tR t^bt o RtR tR tR tR tR t	R t
RtV tR	# )
ÚTraceAdapteral  
Tracks object tree depth and calculates pickled object size.

A single instance of this wraps the module's logger, as the logging API
doesn't allow setting it directly with a custom Logger subclass.  The added
'trace()' method receives a pickle instance as the first argument and
creates extra values to be added in the LogRecord from it, then calls
'info()'.

Usage of logger with 'trace()' method:

>>> from dill.logger import adapter as logger  #NOTE: not dill.logger.logger
>>> ...
>>> def save_atype(pickler, obj):
>>>     logger.trace(pickler, "Message with %s and %r etc. placeholders", 'text', obj)
>>>     ...
c                ó   € Wn         R # ©N©Úlogger)Úselfr   s   &&Ú\/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/dill/logger.pyÚ__init__ÚTraceAdapter.__init__t   s   € ØŽó    c                óx   € \        R VR7      pVP                  V4       V P                  P                  V4       R# )z%(prefix)s%(message)s%(suffix)s)ÚhandlerN)ÚTraceFormatterÚsetFormatterr   Ú
addHandler)r   r   Ú	formatters   && r   r   ÚTraceAdapter.addHandlerv   s/   € Ü"Ð#DÈgÔVˆ	Ø×Ñ˜YÔ'Ø�‰×Ñ˜wÖ'r   c                ó<   € V P                   P                  V4       R # r   )r   ÚremoveHandler)r   r   s   &&r   r   ÚTraceAdapter.removeHandlerz   s   € Ø�‰×!Ñ! 'Ö*r   c                ó   € W3# r   © )r   ÚmsgÚkwargss   &&&r   ÚprocessÚTraceAdapter.process|   s
   € àˆ{Ðr   c                óÐ   € \         P                  P                  VR R7      '       g   R# V P                  \        P
                  4      '       d   ^Vn        . Vn        R# RVn        R# )F)ÚchildN)ÚdillÚ_dillÚis_dillÚisEnabledForÚloggingÚINFOÚ_trace_depthÚ_size_stack)r   Úpicklers   &&r   Útrace_setupÚTraceAdapter.trace_setup   sL   € ä�z‰z×!Ñ! '°Ð!×7Ò7ÙØ×ÑœWŸ\™\×*Ò*Ø#$ˆGÔ Ø"$ˆGÖà#'ˆGÖ r   c                óB  € \        VR 4      '       g   \        P                  ! V.VO5/ VB  R# VP                  f   R# VP	                  R/ 4      pVP                  R4      pRp VP                  P                  4       pVP                  P                  p WxP                  4       ,          pTeI   T'       g   TP                  P                  T4       M$YqP                  P                  4       ,          pYuR&   T'       d   T;P                  ^,          un        TP                  TR&   YTR&   T P                  ! T.TO5/ TB  T'       g   T;P                  ^,          un        R# R#   \         d    T\        T4      ,          p LÚi ; i  \        \        3 d     Lñi ; i)r.   NÚextraÚ#ÚsizeÚdepth)Úhasattrr   Úinfor.   ÚgetÚ
startswithÚ_fileÚtellÚframerÚcurrent_frameÚAttributeErrorÚlenÚ	TypeErrorr/   ÚappendÚpop)	r   r0   r"   Úargsr#   r4   Ú
pushed_objr6   Úframes	   &&&*,    r   ÚtraceÚTraceAdapter.traceˆ   s`  € Ü�w ×/Ò/Ü�KŠK˜Ð-˜dÒ- fÒ-ÙØ×ÑÒ'ÙØ—
‘
˜7 BÓ'ˆØ—^‘^ CÓ(ˆ
Øˆð
	à—=‘=×%Ñ%Ó'ˆDØ—N‘N×0Ñ0ˆEð#ØŸ
™
›Õ$�ð ÒßØ×#Ñ#×*Ñ*¨4Õ0à×+Ñ+×/Ñ/Ó1Õ1�Ø $�f‘ßØ× Ò  AÕ%Õ Ø ×-Ñ-ˆˆg‰Øˆw‰Ø�	Š	�#Ð'˜Ò' Ò'ßØ× Ò  AÕ%× ñ øô! "ô #àœ˜E›
Õ"’ð#ûô ¤	Ð*ô 	Ùð	ús0   Á%0F
 ÂE' Å'FÆF
 ÆFÆF
 Æ
FÆFr   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r   r$   r1   rH   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r   r   r   b   s-   ø‡ € ñò"ò(ò+òò(÷ &ð  &r   r   c                   óJ   a a€ ] tR t^ªt oRtRR/V 3R lltV 3R ltRtVtV ;t	# )r   z¼
Generates message prefix and suffix from record.

This Formatter adds prefix and suffix strings to the log message in trace
mode (an also provides empty string defaults for normal logs).
r   Nc               ó|  <€ \         SV `  ! V/ VB   VP                  P                  pVf   \        h  \        P                  ! V4      P                  pV\        P                  ! R4      P                  8H  V n
        R #   \         d    \
        P                  ! 4       p Lmi ; i  \         d    RT n
         R # i ; i)Nzutf-8F)Úsuperr   ÚstreamÚencodingr@   ÚlocaleÚgetpreferredencodingÚcodecsÚlookupÚnameÚis_utf8ÚLookupError)r   r   rE   r#   rW   Ú	__class__s   &$*, €r   r   ÚTraceFormatter.__init__±   s§   ø€ Ü‰Ò˜$Ð) &Ò)ð	5Ø—~‘~×.Ñ.ˆHØÒÜ$Ð$ð  ð	EÜ—}’} XÓ.×3Ñ3ˆHð %¬¯ª°gÓ(>×(CÑ(CÑCˆDŽLøô ô 	5Ü×2Ò2Ó4ŠHð	5ûô ô 	!Ø ˆD�Lð	!ús"   “ A? µ B% Á? B"Â!B"Â%B;Â:B;c                ó,  <€ R RRR/p\        VR^ 4      ^ 8”  d³   VP                  P                  R4      '       d#   VP                  ^,
          R,          R,           pM5VP                  ^8X  d   RpM!VP                  ^,
          R,          R,           pV P                  '       g   VP                  \        4      R	,           pVR
,           VR &   \        VR4      '       d�   VP                  e‚   VP                  ^8¼  dq   \        \        P                  ! VP                  ^4      4      ^
,          pVP                  V^
,          ,	          pRYT'       d   RV,          R,           MR3,          VR&   \        V4      P                  V4       \        SV `=  V4      # )ÚprefixÚ Úsuffixr7   r5   r   r	   r   u   â”œâ”¬Ú-Ú r6   z	 [%d %sB]ÚKMGTPÚi)Úgetattrr"   r;   r7   r]   Ú	translateÚ	ASCII_MAPr8   r6   ÚintÚmathÚlogÚvarsÚupdaterU   Úformat)r   ÚrecordÚfieldsrb   Úpowerr6   r_   s   &&    €r   rq   ÚTraceFormatter.format¿   s9  ø€ Ø˜B ¨"Ð-ˆÜ�6˜7 AÓ&¨Ô*Ø�z‰z×$Ñ$ S×)Ò)Ø Ÿ,™,¨Õ*¨EÕ1°EÕ9‘Ø—‘ Ô"Ø‘à Ÿ,™,¨Õ*¨EÕ1°HÕ<�Ø—<—<�<Ø×)Ñ)¬)Ó4°sÕ:�Ø%¨�|ˆF�8ÑÜ�6˜6×"Ò" v§{¡{Ò'>À6Ç;Á;ÐRSÔCSäœŸš §¡¨aÓ0Ó1°RÕ7ˆEØ—;‘; %¨¥(Õ*ˆDØ*¨dÎE°G¸EµNÀSÖ4HÐWYÐ-ZÕZˆF�8ÑÜˆV‹×Ñ˜FÔ#Ü‰w‰~˜fÓ%Ð%r   )r]   )
rJ   rK   rL   rM   rN   r   rq   rO   rP   Ú__classcell__)r_   rR   s   @@r   r   r   ª   s"   ù‡ € ñðE d÷ E÷&õ &r   r   r(   FÚmodeÚac                ó~   € V ^8„  d   QhR\         \        \        \        \        P
                  3,          R\        RR/# )é   Úargrw   ÚreturnN)r   Úboolr   ÚstrÚosÚPathLike)rq   s   "r   Ú__annotate__r�   Ù   s4   € ÷ )>ñ )>Œu”Tœ6¤3¬¯©Ð3Õ4ð )>Äcð )>ÐTXñ )>r   c               óÀ   € \        V 4      R9  d   \        WR7      # \        P                  V '       d   \        P
                  4       R# \        P                  4       R# )u  print a trace through the stack when pickling; useful for debugging

With a single boolean argument, enable or disable the tracing.

Example usage:

    >>> import dill
    >>> dill.detect.trace(True)
    >>> dill.dump_session()

Alternatively, ``trace()`` can be used as a context manager. With no
arguments, it just takes care of restoring the tracing state on exit.
Either a file handle, or a file name and (optionally) a file mode may be
specitfied to redirect the tracing output in the ``with`` block context. A
log function is yielded by the manager so the user can write extra
information to the file.

Example usage:

    >>> from dill import detect
    >>> D = {'a': 42, 'b': {'x': None}}
    >>> with detect.trace():
    >>>     dumps(D)
    â”¬ D2: <dict object at 0x7f2721804800>
    â”œâ”¬ D2: <dict object at 0x7f27217f5c40>
    â”‚â”” # D2 [8 B]
    â”” # D2 [22 B]
    >>> squared = lambda x: x**2
    >>> with detect.trace('output.txt', mode='w') as log:
    >>>     log("> D = %r", D)
    >>>     dumps(D)
    >>>     log("> squared = %r", squared)
    >>>     dumps(squared)

Arguments:
    arg: a boolean value, or an optional file-like or path-like object for the context manager
    mode: mode string for ``open()`` if a file name is passed as the first argument
)Úfilerw   N)ÚFalseÚTrue)ÚreprÚTraceManagerr   ÚsetLevelr,   r-   ÚWARNING)r{   rw   s   &$r   rH   rH   Ù   s8   € ôN ˆCƒyÐ)Ô)Ü Ô0Ð0Ü
‡O�O§C”G—L‘LÖ=¬W¯_©_Ö=r   c                   ó6   a € ] tR tRt o RtR tR tR tRtV t	R# )r‡   i  zDcontext manager version of trace(); can redirect the trace to a filec                óR   € Wn         W n        VR JV n        \        VR4      V n        R # )NÚwrite)rƒ   rw   Úredirectr8   Úfile_is_stream)r   rƒ   rw   s   &&&r   r   ÚTraceManager.__init__  s'   € ØŒ	ØŒ	Ø DÐ(ˆŒÜ% d¨GÓ4ˆÖr   c                ó&  € V P                   '       dµ   \        P                  4        V P                  '       d'   \        P
                  ! V P                  4      V n        M0\        P                  ! V P                  V P                  4      V n        \        P                  \        4       \        P                  V P                  4       \        P                  4       V n        \        P                  \        P                   4       \        P"                  # r   )r�   Ústderr_handlerÚflushrŽ   r,   ÚStreamHandlerrƒ   r   ÚFileHandlerrw   Úadapterr   r   ÚgetEffectiveLevelÚ	old_levelrˆ   r-   r9   )r   s   &r   Ú	__enter__ÚTraceManager.__enter__  s¡   € Ø�=�=ˆ=Ü× Ñ Ô"Ø×"×"Ð"Ü&×4Ò4°T·Y±YÓ?�•ä&×2Ò2°4·9±9¸d¿i¹iÓH�”Ü×!Ñ!¤.Ô1Ü×Ñ˜tŸ|™|Ô,Ü ×2Ñ2Ó4ˆŒÜ×ÑœŸ™Ô&Ü�|‰|Ðr   c                ó8  € \         P                  V P                  4       V P                  '       di   \         P	                  V P
                  4       \         P                  \        4       V P                  '       g   V P
                  P                  4        R # R # R # r   )
r•   rˆ   r—   r�   r   r   r   r‘   rŽ   Úclose)r   Úexc_infos   &*r   Ú__exit__ÚTraceManager.__exit__  sc   € Ü×Ñ˜Ÿ™Ô(Ø�=�=ˆ=Ü×!Ñ! $§,¡,Ô/Ü×Ñœ~Ô.Ø×&×&Ð&Ø—‘×"Ñ"Ö$ñ 'ñ r   )rƒ   rŽ   r   rw   r—   r�   N)
rJ   rK   rL   rM   rN   r   r˜   r�   rO   rP   rQ   s   @r   r‡   r‡     s   ø‡ € ÙNò5ò
÷%ð %r   r‡   )r•   r   rH   r   )rN   Ú__all__rZ   Ú
contextlibrX   r,   rm   r   Ú	functoolsr   Útypingr   r   r(   r~   Ú	maketransrk   ÚLoggerAdapterr   Ú	Formatterr   Ú	getLoggerr   Ú	propagater•   Ú_StderrHandlerr‘   r   rH   ÚAbstractContextManagerr‡   r!   r   r   Ú<module>rª      sÛ   ðñ"òH )€ã Û Û Û Û Û 	Ý ß  ã ð �M‰M˜5 # u¨c°5¸#¸uÀcÐJÓK€	ôPF&�7×(Ñ(ô F&ôP'&�W×&Ñ&ô '&ðR 
×	Ò	˜6Ó	"€Ø€Ô Ù
�vÓ
€Ø×'Ò'Ó)€Ø × Ñ �>Ô "ñ)>ÈC÷ )>ð )>ôV%�:×4Ñ4ö %r   