
    a	                         d dl Z d dlZeZe j                  j                  dd      Z G d dej                        ZddZ	y)    Nreprreprlibc                   (    e Zd ZdZd Zd Zd Zd Zy)SafeReprz subclass of repr.Repr that limits the resulting size of repr()
        and includes information on exceptions raised during the call.
    c                 X    | j                  t        j                  j                  | |      S N)_callhelperr   Reprr   )selfxs     1/usr/lib/python3/dist-packages/py/_io/saferepr.pyr   zSafeRepr.repr   s!     1 14;;    c                 D   d } ||d | j                          }t        |      | j                   kD  rot        d| j                   dz
  dz        }t        d| j                   dz
  |z
        } ||d | |t        |      |z
  d  z         }|d | dz   |t        |      |z
  d  z   }|S )Nc                     d| vr"t         j                  j                  d      | z  S d| vr"t         j                  j                  d      | z  S t         j                  j                  d      | j                  dd      z  S )N'z'%s'"z"%s"z\')pybuiltin_totextreplace)us    r   r   z#SafeRepr.repr_unicode.<locals>.repr   si    !|zz))&1A55Azz))&1A55zz))&1AIIc54IIIr   r         ...)	maxstringlenmax)r   r   levelr   sijs          r   repr_unicodezSafeRepr.repr_unicode   s    	J ?DNN#$q6DNN"Aq(1,-AAt~~a')*AQrUQs1vaxy\)*A"1#a&(),Ar   c                 .    | j                  t        |      S r   )r	   builtin_repr)r   r   r   s      r   repr_instancezSafeRepr.repr_instance    s    a00r   c                 2   	  ||g| }t        |      | j                  kD  rRt        d| j                  dz
  dz        }t        d| j                  dz
  |z
        }|d | dz   |t        |      |z
  d  z   }|S # t        j                  j
                  $ r   t        j                         \  }}}	t        |dd      }
	 t        |      }n&# t        j                  j
                  $ r   d}Y nxY wd|
||j                  j                  t        |      fz  cY S xY w)Nr   r   r   r   __name__unknownz/<[%s("%s") raised in repr()] %s object at 0x%x>)r   maxsizer   r   r   _sysexsysexc_infogetattrstr	__class__r'   id)r   callr   argsr   r    r!   clsetbexc_namer,   s               r   r	   zSafeRepr._callhelper#   s   	QA 1v$DLLNQ./4<<>!+,bqEEMAc!fQhiL0H% zz   	
	AJCBsJ	:H%q6::$$ %$D(AKK$8$8"Q%HA A As$   	A7 7AD<CD!C+)+DN)r'   
__module____qualname____doc__r   r"   r%   r	    r   r   r   r      s    <"1r   r   c                 b    t               }||_        ||_        d|_        |j	                  |       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.
       )r   r   r)   maxotherr   )objr)   sreprs      r   safereprr@   ;   s.     JEEOEMEN::c?r   )   )
r   r+   r   r$   r   
_tryimportr   r
   r   r@   r:   r   r   <module>rC      s<    	 

**

	
21w|| 1fr   