a
    ø£BeB  ã                   @   s|   d Z ddlZddlZddlmZ ddd„Zddd„Zdd	d
„Zdd„ Z	ddd„Z
ddd„Ze ¡ dkZddd„Ze ZZdS )z€Compatibility tricks for Python 3. Mainly to do with unicode.

This file is deprecated and will be removed in a future version.
é    Né   )ÚDEFAULT_ENCODINGc                 C   s   |pt }|  |d¡S ©NÚreplace)r   Údecode©ÚsÚencoding© r
   úZ/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/IPython/utils/py3compat.pyr      s    r   c                 C   s   |pt }|  |d¡S r   )r   Úencode)Úur	   r
   r
   r   r      s    r   c                 C   s   t | tƒrt| |ƒS | S ©N)Ú
isinstanceÚbytesr   r   r
   r
   r   Úcast_unicode   s    

r   c                 C   s@   z
t | ƒW S  ty   Y n0 z
t| ƒW S  ty:   Y n0 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)Úer
   r
   r   Úsafe_unicode   s    

r   Ú c                 C   s
   t  | ¡S r   )Úbuiltin_modÚinput)Úpromptr
   r
   r   r   /   s    r   c                 C   s^   |d ur|n|}t | dƒ�0}|p"t}t|| ¡ | dƒ||ƒ W d   ƒ n1 sP0    Y  d S )NÚrbÚexec)ÚopenÚcompiler   Úread)ÚfnameÚglobÚlocÚcompilerÚfr
   r
   r   Úexecfile3   s    r%   ÚPyPyc                 C   s   | S r   r
   )Úxr	   r
   r
   r   Úno_code@   s    r(   )N)N)N)r   )NN)N)Ú__doc__ÚplatformÚbuiltinsr   r	   r   r   r   r   r   r   r%   Úpython_implementationÚPYPYr(   Zunicode_to_strZcast_bytes_py2r
   r
   r
   r   Ú<module>   s   





