
    +h                     $    d dl mZ  G d d      Zy)   )	DataErrorc                   (    e Zd ZdZdZd Zd ZddZy)Encoderz=Encode strings to bytes-like and decode bytes-like to stringsencodingencoding_errorsdecode_responsesc                 .    || _         || _        || _        y )Nr   )selfr   r   r	   s       J/var/www/html/venv/lib/python3.12/site-packages/redis/_parsers/encoders.py__init__zEncoder.__init__	   s     . 0    c                    t        |t        t        f      r|S t        |t              rt	        d      t        |t
        t        f      rt        |      j                         }n4t        |t              s$t        |      j                  }t	        d| d      t        |t              r&|j                  | j                  | j                        }|S )z=Return a bytestring or bytes-like representation of the valuezNInvalid input of type: 'bool'. Convert to a bytes, string, int or float first.zInvalid input of type: 'z2'. Convert to a bytes, string, int or float first.)
isinstancebytes
memoryviewboolr   intfloatreprencodestrtype__name__r   r   )r   valuetypenames      r   r   zEncoder.encode   s    eeZ01Lt$5  U|,K&&(EE3'E{++H*8* 5B C  eS!LL0D0DEEr   c                     | j                   s|rVt        |t              r|j                         }t        |t              r&|j                  | j                  | j                        }|S )z:Return a unicode string from the bytes-like representation)r	   r   r   tobytesr   decoder   r   )r   r   forces      r   r   zEncoder.decode%   sK      E%,%'T]]D4H4HIr   N)F)r   
__module____qualname____doc__	__slots__r   r   r    r   r   r   r      s    CAI1
.r   r   N)
exceptionsr   r   r%   r   r   <module>r'      s    "( (r   