Hacked By AnonymousFox
B
�A�[� � @ s� d Z ddlZddlZddlmZ dZdd� Zdd� ZejrHe Z
d d
� ZneZ
e Zdd� Z
G d
d� de�Zdd� Zdd� Zdd� Zdd� ZdZed�Zed�Ze�e�jZdd� Zedkr�dS )z�
This is Victor Stinner's pure-Python implementation of PEP 383: the "surrogateescape" error
handler of Python 3.
Source: misc/python/surrogateescape.py in https://bitbucket.org/haypo/misc
� N)�utils�surrogateescapec C s t jr
| S | �d�S d S )NZunicode_escape)r �PY3�decode)�text� r �M/opt/alt/python37/lib/python3.7/site-packages/future/utils/surrogateescape.py�u s r c C s t jr| �d�S | S d S )N�latin1)r r �encode)�datar r r �b s
r
c C s
t | f�S )N)�bytes)�coder r r �<lambda># � r c C sf | j | j| j� }y0t| t�r(t|�}nt| t�r<t|�}n| �W n tk
rZ | �Y nX || jfS )z�
Pure Python implementation of the PEP 383: the "surrogateescape" error
handler of Python 3. Undecodable bytes will be replaced by a Unicode
character U+DCxx on decoding, and these are translated into the
original bytes on encoding.
) �object�start�end�
isinstance�UnicodeDecodeError�replace_surrogate_decode�UnicodeEncodeError�replace_surrogate_encode�NotASurrogateError)�exc�mystring�decodedr r r �surrogateescape_handler( s
r c @ s e Zd ZdS )r N)�__name__�
__module__�__qualname__r r r r r C s r c C s� g }xz| D ]r}t |�}d| kr*dks0n t�d| krDdkr\n n|�t|d �� q
|dkrx|�t|d �� q
t�q
W t� �|�S )z�
Returns a (unicode) string, not the more logical bytes, because the codecs
register_error functionality expects this.
i � i�� i � i� )�ordr �append�_unichr�str�join)r r �chr r r r r G s
r c C s~ g }xl| D ]d}t |t�r|}nt|�}d| kr:dkrRn n|�td| �� q
|dkrj|�t|�� q
t�q
W t� �|�S )z$
Returns a (unicode) string
� � i � � )r �intr"