Ë
    çÍ:jÐ  ã                  óª   — d Z ddlmZ ddlZddlZddlmZmZ dZ G d„ dej                  «      Z
 G d„ d	ej                  «      Zdd
dœ	 	 	 	 	 	 	 dd„Zy)a>  
Helpers for safer and/or more explicit pickle usage in NLTK.

- RestrictedUnpickler: blocks unpickling of *any* globals (classes/functions).
  Intended for loading NLTK data packages where we control the serialization.
- WarningUnpickler: emits a security warning before unpickling (does not make
  unpickling safe).
é    )ÚannotationsN)ÚAnyÚBinaryIOz Security warning: loading pickles can execute arbitrary code. Only load pickle files from trusted sources and never from untrusted or unauthenticated locations.c                  ó   — e Zd ZdZdd„Zy)ÚRestrictedUnpicklerzW
    Unpickler that prevents any class or function from being used during loading.
    c                ó:   — t        j                  d|› d|› d�«      ‚)Nzglobal 'ú.z' is forbidden)ÚpickleÚUnpicklingError)ÚselfÚmoduleÚnames      úc/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/nltk/picklesec.pyÚ
find_classzRestrictedUnpickler.find_class$   s"   € ä×$Ñ$ x°¨x°q¸¸¸nÐ%MÓNÐNó    N)r   Ústrr   r   Úreturnr   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   © r   r   r   r      s   „ ñôOr   r   c                  ó6   ‡ — e Zd ZdZddœdˆ fd„Zdˆ fd„Zˆ xZS )ÚWarningUnpicklerz6Unpickler that emits PICKLE_WARNING once per instance.N©Úcontextc               óB   •— t        ‰| �  |fi |¤Ž || _        d| _        y )NF)ÚsuperÚ__init__Ú_contextÚ_warned)r   Úfiler   ÚkwargsÚ	__class__s       €r   r   zWarningUnpickler.__init__,   s#   ø€ Ü‰Ñ˜Ñ( Ò(ØˆŒØˆ�r   c                óÎ   •— | j                   sK| j                  €t        nt        › d| j                  › d�}t        j                  |t
        d¬«       d| _         t        ‰| �  «       S )Nz (ú)é   )Ú
stacklevelT)r!   r    ÚPICKLE_WARNINGÚwarningsÚwarnÚRuntimeWarningr   Úload)r   Úmsgr$   s     €r   r-   zWarningUnpickler.load1   sZ   ø€ Ø�|Š|ð —=‘=Ð(õ ä&Ð' r¨$¯-©-¨¸Ð:ð ô
 �M‰M˜#œ~¸!Õ<ØˆDŒLÜ‰w‰|‹~Ðr   )r"   r   r   ú
str | Noner#   r   )r   r   )r   r   r   r   r   r-   Ú__classcell__)r$   s   @r   r   r   )   s   ø„ Ù@à@D÷ ÷
	ñ 	r   r   F)r   Ú
restrictedc               ón   — |rt        | «      j                  «       S t        | |¬«      j                  «       S )zÎ
    Convenience wrapper similar to pickle.load(file).

    - If restricted=True, uses RestrictedUnpickler (no warning by default).
    - If restricted=False, uses WarningUnpickler and emits a warning.
    r   )r   r-   r   )r"   r   r1   s      r   Úpickle_loadr3   =   s1   € ñ Ü" 4Ó(×-Ñ-Ó/Ð/Ü˜D¨'Ô2×7Ñ7Ó9Ð9r   )r"   r   r   r/   r1   Úboolr   r   )r   Ú
__future__r   r
   r*   Útypingr   r   r)   Ú	Unpicklerr   r   r3   r   r   r   ú<module>r8      st   ðñõ #ã Û ß  ð$ð ôO˜&×*Ñ*ô Oô�v×'Ñ'ô ð* .2Àeñ:Ø
ð:Ø *ð:Ø?Cð:àô:r   