Skip to content

Commit 8b9c39d

Browse files
committed
fix the byte2int import in tests.
1 parent 79716a5 commit 8b9c39d

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

pymysqlreplication/row_event.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3+
import sys
34
import struct
45
import decimal
56
import datetime
@@ -531,6 +532,12 @@ def _dump(self):
531532
row["after_values"][key]))
532533

533534

535+
536+
_need_byte2int = False
537+
if sys.version.startswith('2') or sys.version.startswith('3.4'):
538+
_need_byte2int = True
539+
540+
534541
class TableMapEvent(BinLogEvent):
535542
"""This event describes the structure of a table.
536543
It's sent before a change happens on a table.
@@ -594,6 +601,9 @@ def __init__(self, from_packet, event_size, table_map, ctl_connection, **kwargs)
594601
self.packet.read_length_coded_binary()
595602
for i in range(0, len(column_types)):
596603
column_type = column_types[i]
604+
if _need_byte2int:
605+
column_type = byte2int(column_types[i])
606+
597607
try:
598608
column_schema = self.column_schemas[ordinal_pos_loc]
599609

@@ -617,7 +627,7 @@ def __init__(self, from_packet, event_size, table_map, ctl_connection, **kwargs)
617627
'COLUMN_TYPE': 'BLOB', # we don't know what it is, so let's not do anything with it.
618628
'COLUMN_KEY': '',
619629
}
620-
col = Column(int(column_type), column_schema, from_packet)
630+
col = Column(column_type, column_schema, from_packet)
621631
self.columns.append(col)
622632

623633
self.table_obj = Table(self.column_schemas, self.table_id, self.schema,

pymysqlreplication/tests/binlogfilereader.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'''Read binlog files'''
22
import struct
33

4-
from pymysql.util import byte2int
4+
from six import byte2int
55
from pymysqlreplication import constants
66
from pymysqlreplication.event import FormatDescriptionEvent
77
from pymysqlreplication.event import QueryEvent

pymysqlreplication/tests/test_data_type.py

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
else:
99
import unittest
1010

11+
import json
1112
from decimal import Decimal
1213

1314
from pymysqlreplication.tests import base

0 commit comments

Comments
 (0)