????
Current Path : /lib/python3.6/site-packages/future/utils/__pycache__/ |
Current File : //lib/python3.6/site-packages/future/utils/__pycache__/surrogateescape.cpython-36.pyc |
3 �c� � @ s� d Z ddlZddlZddlmZ dZdd� Zdd� ZejrHe Z d d � ZneZ e Zdd� Z G d d� de�Zdd� Zdd� Zdd� Zdd� ZdZed�Zed�Zeje�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 | jd�S d S )NZunicode_escape)r �PY3�decode)�text� r �%/usr/lib/python3.6/surrogateescape.py�u s r c C s t jr| jd�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># s 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 }x|| D ]t}t |�}d| ko(dkn s2t�d| koDdkn r^|jt|d �� q |dkrz|jt|d �� q t�q W t� j|�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| ko8dkn rR|jtd| �� q |dkrj|jt|�� q t�q W t� j|�S )z$ Returns a (unicode) string � � i � � )r �intr! r"