Mini Shell
3
��\� � @ s0 d dl Z ee jjd�d �ZG dd� de�ZdS )� N�.c @ s e Zd ZdZdd� ZdS )�SafeStrz�
String class that has a modified __add__ method so that ascii strings,
binary data represented as a byte string and unicode objects can be
safely appended to it (not causing traceback). BINARY DATA IS OMITTED.
c C s� t dkrttj| t|���S t|t�p.t|t�sHt|d�rD|j� }nd}t|t�rjttj| |jd���}njy|j d� ttj| |��}W nJ t
k
r� dd� |D �}dd� |D �}dj|�}ttj| |��}Y nX |S ) N� �__str__z%OMITTED OBJECT WITHOUT __str__ METHODzutf-8c s s | ]}t t|��V qd S )N)�hex�ord)�.0�char� r
�!/usr/lib/python3.6/safe_string.py� <genexpr>@ s z"SafeStr.__add__.<locals>.<genexpr>c s s | ]}|j d d�V qdS )Z0xz\xN)�replace)r Zhex_numr
r
r r A s � )�PYr �str�__add__�
isinstanceZunicode�hasattrr �encode�decode�UnicodeDecodeError�join)�self�other�retZ
other_hexaZother_backslashedZ
other_reprr
r
r r ( s$
zSafeStr.__add__N)�__name__�
__module__�__qualname__�__doc__r r
r
r
r r s r )�sys�int�version�splitr r r r
r
r
r �<module> s