Your IP : 216.73.216.61


Current Path : /opt/alt/python37/lib/python3.7/site-packages/py/_io/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/py/_io/__pycache__/saferepr.cpython-37.pyc

B

���]�	�@sBddlZddlZeZej�dd�ZGdd�dej�Zd	dd�Z	dS)
�N�repr�reprlibc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�SafeReprz� subclass of repr.Repr that limits the resulting size of repr()
        and includes information on exceptions raised during the call.
    cCs|�tjj||�S)N)�_callhelperr�Reprr)�self�x�r	�@/opt/alt/python37/lib/python3.7/site-packages/py/_io/saferepr.pyrsz
SafeRepr.reprcCs�dd�}||d|j��}t|�|jkr�td|jdd�}td|jd|�}||d|�|t|�|d��}|d|�d|t|�|d�}|S)NcSsLd|krtj�d�|Sd|kr0tj�d�|Stj�d�|�dd�SdS)N�'z'%s'�"z"%s"z\')�py�builtinZ_totext�replace)�ur	r	r
rs
z#SafeRepr.repr_unicode.<locals>.reprr��z...)�	maxstring�len�max)rr�levelr�s�i�jr	r	r
�repr_unicodes$$zSafeRepr.repr_unicodecCs|�t|�S)N)r�builtin_repr)rrrr	r	r
�
repr_instance szSafeRepr.repr_instancecGs�y||f|��}Wn�tjjk
r,�Yn�t��\}}}t|dd�}yt|�}	Wn(tjjk
rr�Ynd}	YnXd||	|jjt	|�fSt
|�|jkr�td|jdd�}
td|jd|
�}|d|
�d|t
|�|d�}|SdS)N�__name__�unknownz/<[%s("%s") raised in repr()] %s object at 0x%x>rrrz...)
r
rZ_sysex�sys�exc_info�getattr�str�	__class__r�idr�maxsizer)r�callr�argsr�cls�e�tbZexc_namer rrr	r	r
r#s(
$zSafeRepr._callhelperN)r�
__module__�__qualname__�__doc__rrrrr	r	r	r
rs
r��cCs"t�}||_||_d|_|�|�S)aP return a size-limited safe repr-string for the given object.
    Failing __repr__ functions of user instances will be represented
    with a short exception info and 'saferepr' generally takes
    care to never raise exceptions itself.  This function is a wrapper
    around the Repr/reprlib functionality of the standard 2.6 lib.
    �)rrr%�maxotherr)�objr%Zsreprr	r	r
�saferepr;s
r2)r.)
r
rrrrZ
_tryimportrrrr2r	r	r	r
�<module>s
3