HEX
Server: Apache
System: Linux srv1.prosuiteplus.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: prosuiteplus (1001)
PHP: 8.3.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/future/utils/__pycache__/surrogateescape.cpython-38.pyc
U

,�]��@s�dZddlZddlZddlmZdZdd�Zdd�ZejrHe	Z
d	d
�ZneZ
e	Zdd�Z
Gd
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�surrogateescapecCstjr
|S|�d�SdS)NZunicode_escape)r�PY3�decode)�text�r�>/usr/lib/python3/dist-packages/future/utils/surrogateescape.py�usr	cCstjr|�d�S|SdS)N�latin1)rr�encode)�datarrr�bs
r
cCs
t|f�S�N)�bytes)�coderrr�<lambda>#�rcCsf|j|j|j�}z0t|t�r(t|�}nt|t�r<t|�}n|�Wntk
rZ|�YnX||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�decodedrrr�surrogateescape_handler(s




rc@seZdZdS)rN)�__name__�
__module__�__qualname__rrrrrCsrcCs�g}|D]r}t|�}d|kr(dks.nt�d|krBdkrZnn|�t|d��q|dkrv|�t|d��qt�qt��|�S)z�
    Returns a (unicode) string, not the more logical bytes, because the codecs
    register_error functionality expects this.
    ������i�)�ordr�append�_unichr�str�join)rr�chrrrrrGsrcCszg}|D]d}t|t�r|}nt|�}d|kr8dkrPnn|�td|��q|dkrh|�t|��qt�qt��|�S)z$
    Returns a (unicode) string
    ��r%�)r�intr&r'r(rr)r*)Zmybytesrr+rrrrrds
rcCs@tdkr�g}t|�D]f\}}t|�}|dkr6t|�}n:d|krJdkr\nnt|d�}ntt|||dd��|�|�qt��|�Stdk�r0g}t|�D]�\}}t|�}d	|kr�d
k�rnnFd|kr�dkr�nnt|d�}|�|�ntt|||dd��q�|�d�}|�|�q�t��|�S|�tt	�SdS)N�asciir,i��r$r%�zordinal not in range(128)zutf-8r#i��zsurrogates not allowed)
�FS_ENCODING�	enumerater&�	bytes_chrrr'rr*r�	FS_ERRORS)�fn�encoded�indexr+rZch_utf8rrr�encodefilename}sF
�
�
r9cCs|�tt�Sr)rr2r5)r6rrr�decodefilename�sr:r0u[abcÿ]u[abc�]cCs>tjr
dSzt�t�Wn tk
r8t�tt�YnXdS)zH
    Registers the surrogateescape error handler on Python 2 (only)
    N)rr�codecs�lookup_errorr5�LookupError�register_errorrrrrr�register_surrogateescape�sr?�__main__)�__doc__r;�sysZfuturerr5r	r
r�chrr(r4Zunichrr�	Exceptionrrrr9r:r2r6r7�lookup�namer?r rrrr�<module>s0	
'