U Yzf_@sdZddlmZddlZddlZddlmZejddkZerje e eee fZ e e fZ efZeefZefZn&e e eefZ e fZ efZefZeefZdd d Zd d Zd dZerddZnejZddZdS)z Python v2 to v3 migration module)DecimalN) HexLiteralutf-8cCsnt|tr|Strt|St|tr,t|St|tsfzt|j|dWStk rdtdYnXt|S)z(Initializes a bytearray from the payload)encodingzpayload must be a str or bytes) isinstance bytearrayPY2intbytesencodeAttributeError ValueError)payloadrro/private/var/folders/n9/53xbvtmd7sjg1q1l55xmpg58n4mgng/T/pip-unpacked-wheel-47tvuv7y/mysql/connector/catch23.pyinit_bytearray7s   rcCstrt|tSt|tS)z&Returns whether a variable is a string)r r basestringstrobjrrrisstrJs rcCstrt|tSt|tS)z/Returns whether a variable is a of unicode type)r r unicoderrrrr isunicodePs rcCs*t|ttfrt|t|St||S)zAWrapper around struct.unpack handling buffer as bytes and strings)r r r struct unpack_frombuffer)fmtbufrrr struct_unpackXsr!csfdd}|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. csL|j}dD]}||dq|j}tr4||d<n |f|}|j||S)ZWrapper)__dict__ __weakref__N __metaclass__)r"copypop __bases__r __name__)class_attrsattrbases base_classrrwrapperhs   zmake_abc..wrapperr)r.r/rr-rmake_abcas r0)rr)__doc__decimalrrsysZ custom_typesr version_infor r floatlongZ NUMERIC_TYPESZ INT_TYPESrZ UNICODE_TYPESrZ STRING_TYPESr Z BYTE_TYPESr rrrr!unpackr0rrrrs.