HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/future/utils/__pycache__/surrogateescape.cpython-310.pyc
o

,�]��@s�dZddlZddlZddlmZdZdd�Zdd�Zejr$e	Z
d	d
�ZneZ
e	Zdd�Z
Gd
d�de�Zdd�Zdd�Zdd�Zdd�ZdZed�Zed�Ze�e�jZdd�Zedkr_	dSdS)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�S)N�unicode_escape)r�PY3�decode)�text�r�>/usr/lib/python3/dist-packages/future/utils/surrogateescape.py�us
r
cCstjr|�d�S|S)N�latin1)rr�encode)�datarrr	�bs
rcCs
t|f�S�N)�bytes)�coderrr	�<lambda>#s
rcCs`|j|j|j�}zt|t�rt|�}nt|t�rt|�}n|�Wn	ty*|�w||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__rrrr	rCsrcCs�g}|D]9}t|�}d|krdkst�t�d|kr"dkr.nn
|�t|d��q|dkr<|�t|d��qt�t��|�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�chrrrr	rGs�rcCsxg}|D]1}t|t�r|}nt|�}d|krdkr(nn
|�td|��q|dkr4|�t|��qt�t��|�S)z$
    Returns a (unicode) string
    ��r%�)r�intr&r'r(rr)r*)�mybytesrr+rrrr	rds
rcCs6tdkrDg}t|�D]3\}}t|�}|dkrt|�}nd|kr%dkr.nnt|d�}n
tt|||dd��|�|�q
t��|�Stdkr�g}t|�D]@\}}t|�}d	|kr`d
kr�nn"d|krldkrznnt|d�}|�|�qNtt|||dd��|�d�}|�|�qNt��|�S|�tt	�S)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+r�ch_utf8rrr	�encodefilename}s<

��
r;cCs|�tt�Sr)rr3r6)r7rrr	�decodefilename�sr<r1u[abcÿ]u[abc�]cCs<tjrdSzt�t�WdStyt�tt�YdSw)zH
    Registers the surrogateescape error handler on Python 2 (only)
    N)rr�codecs�lookup_errorr6�LookupError�register_errorrrrrr	�register_surrogateescape�s�rA�__main__)�__doc__r=�sys�futurerr6r
rr�chrr(r5�unichrr�	Exceptionrrrr;r<r3r7r8�lookup�namerAr rrrr	�<module>s0	
'�