Skip to content

Use a simplifed byte2int #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pymysqlreplication/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import struct
import datetime

from pymysql.util import byte2int, int2byte
from .util import byte2int, int2byte


class BinLogEvent(object):
Expand Down
2 changes: 1 addition & 1 deletion pymysqlreplication/packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import struct

from pymysql.util import byte2int

from pymysqlreplication import constants, event, row_event
from .util import byte2int

# Constants from PyMYSQL source code
NULL_COLUMN = 251
Expand Down
3 changes: 1 addition & 2 deletions pymysqlreplication/row_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import decimal
import datetime

from pymysql.util import byte2int

from .util import byte2int
from .event import BinLogEvent
from .constants import FIELD_TYPE
from .constants import BINLOG
Expand Down
10 changes: 10 additions & 0 deletions pymysqlreplication/util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import struct

def byte2int(b):
try:
return struct.unpack("!B", b)[0]
except TypeError: #With python 3 some read return int
return b

def int2byte(i):
return struct.pack("!B", i)