U
    >vf<  ã                   @  s–   d Z ddlmZ ddlZddlmZ ddlmZ zddlZdZ	W n e
k
rX   dZ	Y nX dd	d
œdd„ZG dd„ dejƒZe	r’G dd„ dejƒZdS )zC
Patched ``BZ2File`` and ``LZMAFile`` to handle pickle protocol 5.
é    )ÚannotationsN)ÚPickleBuffer)ÚPY310TFz-bytes | bytearray | memoryview | PickleBufferzbytes | bytearray | memoryview)ÚbÚreturnc                 C  sV   t | ttfƒr| S t | tƒs$t| ƒ} z
|  ¡ W S  tk
rP   t| ƒ d¡ Y S X dS )z²
    Return some 1-D `uint8` typed buffer.

    Coerces anything that does not match that description to one that does
    without copying if possible (otherwise will copy).
    ÚAN)Ú
isinstanceÚbytesÚ	bytearrayr   ÚrawÚBufferErrorÚ
memoryviewÚtobytes)r   © r   ú=/tmp/pip-unpacked-wheel-vdrwu74i/pandas/compat/compressors.pyÚflatten_buffer   s    


r   c                      s&   e Zd Zesddœ‡ fdd„Z‡  ZS )ÚBZ2FileÚint©r   c                   s   t ƒ  t|ƒ¡S ©N©ÚsuperÚwriter   ©Úselfr   ©Ú	__class__r   r   r   /   s    zBZ2File.write©Ú__name__Ú
__module__Ú__qualname__r   r   Ú__classcell__r   r   r   r   r   ,   s   r   c                      s&   e Zd Zesddœ‡ fdd„Z‡  ZS )ÚLZMAFiler   r   c                   s   t ƒ  t|ƒ¡S r   r   r   r   r   r   r   >   s    zLZMAFile.writer   r   r   r   r   r"   ;   s   r"   )Ú__doc__Ú
__future__r   Úbz2Úpickler   Zpandas.compat._constantsr   ÚlzmaZhas_lzmaÚImportErrorr   r   r"   r   r   r   r   Ú<module>   s   
