3
(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rje	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rdd ZnejZdd ZdS )z Python v2 to v3 migration module    )DecimalN   )
HexLiteral       utf-8c             C   sl   t | tr| S trt| S t | tr,t| S t | tsdyt| j|dS  tk
rb   tdY nX 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   K/tmp/pip-install-q3hcpn_q/mysql-connector-python/mysql/connector/catch23.pyinit_bytearray7   s    


r   c             C   s   t rt| tS t| tS )z&Returns whether a variable is a string)r   r	   
basestringstr)objr   r   r   isstrJ   s    
r   c             C   s   t rt| tS t| tS )z/Returns whether a variable is a of unicode type)r   r	   unicoder   )r   r   r   r   	isunicodeP   s    
r   c             C   s*   t |ttfrtj| t|S tj| |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 )zDecorator 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                sP   | j j }xdD ]}|j|d qW | j}tr8| |d< n
| f| } | j||S )ZWrapper__dict____weakref__N__metaclass__)r!   r"   )r!   copypop	__bases__r   __name__)class_attrsattrbases)
base_classr   r   wrapperh   s    



zmake_abc.<locals>.wrapperr   )r,   r-   r   )r,   r   make_abca   s    r.   )r   r   )__doc__decimalr   r   sysZcustom_typesr   version_infor   r   floatlongZNUMERIC_TYPESZ	INT_TYPESr   ZUNICODE_TYPESr   ZSTRING_TYPESr
   Z
BYTE_TYPESr   r   r   r   r    unpackr.   r   r   r   r   <module>   s.   

