o
    –¨Êh  ã                   @   sÊ   d Z ddlmZ ddlZddlZddlmZ ejd dkZer5e	e
eeefZe	efZefZeefZefZne	e
eefZe	fZefZefZeefZdd	d
„Zdd„ Zdd„ Zer\dd„ ZnejZdd„ ZdS )z Python v2 to v3 migration moduleé    )ÚDecimalNé   )Ú
HexLiteralé   ó    úutf-8c                 C   sh   t | tƒr| S trt| ƒS t | tƒrt| ƒS t | tƒs0z	t| j|d�ƒW S  ty/   tdƒ‚w t| ƒS )z(Initializes a bytearray from the payload)Úencodingzpayload must be a str or bytes)Ú
isinstanceÚ	bytearrayÚPY2ÚintÚbytesÚencodeÚAttributeErrorÚ
ValueError)Úpayloadr   © r   úI/var/www/html/env/lib/python3.10/site-packages/mysql/connector/catch23.pyÚinit_bytearray7   s   


ÿr   c                 C   ó   t rt| tƒS t| tƒS )z&Returns whether a variable is a string)r   r	   Ú
basestringÚstr©Úobjr   r   r   ÚisstrJ   ó   

r   c                 C   r   )z/Returns whether a variable is a of unicode type)r   r	   Úunicoder   r   r   r   r   Ú	isunicodeP   r   r   c                 C   s*   t |ttfƒrt | t|ƒ¡S t | |¡S )zAWrapper around struct.unpack handling buffer as bytes and strings)r	   r
   r   ÚstructÚunpack_fromÚbuffer)ÚfmtÚbufr   r   r   Ústruct_unpackX   s   r#   c                    s   ‡ fdd„}|S )zåDecorator used to create a abstract base class

    We use this decorator to create abstract base classes instead of
    using the abc-module. The decorator makes it possible to do the
    same in both Python v2 and v3 code.
    c                    sL   | j  ¡ }dD ]}| |d¡ q| j}tr| |d< n| f| }ˆ | j||ƒS )ÚWrapper)Ú__dict__Ú__weakref__NÚ__metaclass__)r%   ÚcopyÚpopÚ	__bases__r   Ú__name__)Úclass_ÚattrsÚattrÚbases©Ú
base_classr   r   Úwrapperh   s   


zmake_abc.<locals>.wrapperr   )r1   r2   r   r0   r   Úmake_abca   s   r3   )r   r   )Ú__doc__Údecimalr   r   ÚsysÚcustom_typesr   Úversion_infor   r   ÚfloatÚlongÚNUMERIC_TYPESÚ	INT_TYPESr   ÚUNICODE_TYPESr   ÚSTRING_TYPESr
   Ú
BYTE_TYPESr   r   r   r   r#   Úunpackr3   r   r   r   r   Ú<module>   s0   

