
    j                         d Z ddlZddlZddlmZ ddlmZ ddede	dz  de	fd	Z
dd
e	dee	         defdZdde	ez  dee	         de	fdZd ZddZddZ ej                    dk    ZdS )zCompatibility tricks for Python 3. Mainly to do with unicode.

This file is deprecated and will be removed in a future version.
    N   )DEFAULT_ENCODING)Optionalsencodingreturnc                 @    |pt           }|                     |d          S Nreplace)r   decoder   r   s     ^/home/ubuntu/.hermes/hermes-agent/venv/lib/python3.11/site-packages/IPython/utils/py3compat.pyr   r      !    ++H88Hi(((    uc                 @    |pt           }|                     |d          S r
   )r   encode)r   r   s     r   r   r      r   r   c                 P    t          | t                    rt          | |          S | S N)
isinstancebytesr   r   s     r   cast_unicoder      s)    !U #a"""Hr   c                     	 t          |           S # t          $ r Y nw xY w	 t          |           S # t          $ r Y nw xY wdS )zlunicode(e) with various fallbacks. Used for exceptions, which may not be
    safe to call unicode() on.
    zUnrecoverably corrupt evalue)strUnicodeErrorrepr)es    r   safe_unicoder      sj    1vv   Aww    *)s    
1 
>> c                 *    t          j        |           S r   )builtin_modinput)prompts    r   r"   r"   1   s    V$$$r   c                     ||n|}t          | d          5 }|pt          }t           ||                                | d          ||           d d d            d S # 1 swxY w Y   d S )Nrbexec)opencompiler&   read)fnameglobloccompilerfs        r   execfiler/   5   s    /##C	eT		 ;a&wXXaffhhv..c:::; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;s   8AA #A PyPyr   )r   )NN)__doc__platformbuiltinsr!   r   r   typingr   r   r   r   r   r   r   r"   r/   python_implementationPYPY r   r   <module>r8      s6   
      & & & & & &      ) )e )sTz )S ) ) ) )
) )c )Xc] )E ) ) ) )
 C%K 8C= #    * * *&% % % %; ; ; ; &x%''61r   