U e @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)payloadrrl/opt/hc_python/lib64/python3.8/site-packages/../../../lib/python3.8/site-packages/mysql/connector/catch23.pyinit_bytearray2s   rcCstrt|tSt|tSdS)z&Returns whether a variable is a stringN)r r basestringstrobjrrrisstrFs rcCstrt|tSt|tSdS)z/Returns whether a variable is a of unicode typeN)r r unicoderrrrr isunicodeMs rcCs*t|ttfrt|t|St||S)zAWrapper around struct.unpack handling buffer as bytes and strings)r r r struct unpack_frombuffer)fmtbufrrr struct_unpackVsr!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__NZ __metaclass__)r"copypop __bases__r __name__)class_attrsattrbases base_classrrwrapperfs   zmake_abc..wrapperr)r-r.rr,rmake_abc_s r/)rr)__doc__decimalrrsysZ custom_typesr version_infor r floatlongZ NUMERIC_TYPESZ INT_TYPESrZ UNICODE_TYPESrZ STRING_TYPESr Z BYTE_TYPESr rrrr!unpackr/rrrrs.