a
    m¬zf#  ã                   @   sØ   d Z ddlZddlZzddlZejdkZ[W n eyB   dZY n0 ee d¡ƒZ	ee d¡ƒZ
e ¡ dkZe ¡ ZedkZedkZed	kZed
kZe ¡ Ze d¡Zddd„Zddd„Zddd„Zdd„ Zdd„ ZdS )zECompatibility code for using Cheroot with various versions of Python.é    N)é   r   ÚCIZGITHUB_WORKFLOWÚPyPyÚWindowsÚLinuxÚDarwinÚSunOSÚppcú
ISO-8859-1c                 C   s   t | ƒ |  |¡S )z8Return the native string as bytes in the given encoding.)Úassert_nativeÚencode©ÚnÚencoding© r   ú=/var/www/media/lib/python3.9/site-packages/cheroot/_compat.pyÚntob!   s    r   c                 C   s   t | ƒ | S )z<Return the native string as Unicode with the given encoding.)r   r   r   r   r   Úntou(   s    r   c                 C   s
   |   |¡S )z>Return the byte string as native string in the given encoding.)Údecode)Úbr   r   r   r   Úbton/   s    r   c                 C   s    t | tƒstdt| ƒj ƒ‚dS )zxCheck whether the input is of native :py:class:`str` type.

    Raises:
        TypeError: in case of failed check

    zn must be a native str (got %s)N)Ú
isinstanceÚstrÚ	TypeErrorÚtypeÚ__name__)r   r   r   r   r   4   s    
r   c                 C   s,   t | tƒr|  ¡ S t | tƒr | S tdƒ‚dS )aR  Retrieve bytes out of the given input buffer.

    :param mv: input :py:func:`buffer`
    :type mv: memoryview or bytes

    :return: unwrapped bytes
    :rtype: bytes

    :raises ValueError: if the input is not one of \
                        :py:class:`memoryview`/:py:func:`buffer` \
                        or :py:class:`bytes`
    z8extract_bytes() only accepts bytes and memoryview/bufferN)r   Ú
memoryviewÚtobytesÚbytesÚ
ValueError)Úmvr   r   r   Úextract_bytes?   s    

ÿr!   )r
   )r
   )r
   )Ú__doc__ÚosÚplatformÚsslÚOPENSSL_VERSION_INFOZIS_ABOVE_OPENSSL10ÚImportErrorÚboolÚgetenvZIS_CIZIS_GITHUB_ACTIONS_WORKFLOWÚpython_implementationZIS_PYPYÚsystemZSYS_PLATFORMZ
IS_WINDOWSZIS_LINUXZIS_MACOSZ
IS_SOLARISÚmachineZPLATFORM_ARCHÚ
startswithZIS_PPCr   r   r   r   r!   r   r   r   r   Ú<module>   s.   





