Skip to content

remove util.py #923

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

Merged
merged 4 commits into from
Jan 3, 2021
Merged
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
7 changes: 3 additions & 4 deletions pymysql/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
EOFPacketWrapper,
LoadLocalPacketWrapper,
)
from .util import byte2int, int2byte
from . import err, VERSION_STRING

try:
Expand Down Expand Up @@ -76,7 +75,7 @@ def _lenenc_int(i):
"Encoding %d is less than 0 - no representation in LengthEncodedInteger" % i
)
elif i < 0xFB:
return int2byte(i)
return bytes([i])
elif i < (1 << 16):
return b"\xfc" + struct.pack("<H", i)
elif i < (1 << 24):
Expand Down Expand Up @@ -675,7 +674,7 @@ def write_packet(self, payload):
"""
# Internal note: when you build packet manually and calls _write_bytes()
# directly, you should set self._next_seq_id properly.
data = _pack_int24(len(payload)) + int2byte(self._next_seq_id) + payload
data = _pack_int24(len(payload)) + bytes([self._next_seq_id]) + payload
if DEBUG:
dump_packet(data)
self._write_bytes(data)
Expand Down Expand Up @@ -1056,7 +1055,7 @@ def _get_server_information(self):
packet = self._read_packet()
data = packet.get_all_data()

self.protocol_version = byte2int(data[i : i + 1])
self.protocol_version = data[i]
i += 1

server_end = data.find(b"\0", i)
Expand Down
9 changes: 3 additions & 6 deletions pymysql/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from .charset import MBLENGTH
from .constants import FIELD_TYPE, SERVER_STATUS
from . import err
from .util import byte2int

import struct
import sys
Expand All @@ -21,10 +20,8 @@

def dump_packet(data): # pragma: no cover
def printable(data):
if 32 <= byte2int(data) < 127:
if isinstance(data, int):
return chr(data)
return data
if 32 <= data < 127:
return chr(data)
return "."

try:
Expand All @@ -38,7 +35,7 @@ def printable(data):
dump_data = [data[i : i + 16] for i in range(0, min(len(data), 256), 16)]
for d in dump_data:
print(
" ".join("{:02X}".format(byte2int(x)) for x in d)
" ".join("{:02X}".format(x) for x in d)
+ " " * (16 - len(d))
+ " " * 2
+ "".join(printable(x) for x in d)
Expand Down
3 changes: 1 addition & 2 deletions pymysql/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import pytest

from pymysql import util
import pymysql.cursors
from pymysql.tests import base
from pymysql.err import ProgrammingError
Expand Down Expand Up @@ -44,7 +43,7 @@ def test_datatypes(self):
)
c.execute("select b,i,l,f,s,u,bb,d,dt,td,t,st from test_datatypes")
r = c.fetchone()
self.assertEqual(util.int2byte(1), r[0])
self.assertEqual(b"\x01", r[0])
self.assertEqual(v[1:10], r[1:10])
self.assertEqual(
datetime.timedelta(0, 60 * (v[10].hour * 60 + v[10].minute)), r[10]
Expand Down
1 change: 0 additions & 1 deletion pymysql/tests/test_nextset.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest

import pymysql
from pymysql import util
from pymysql.tests import base
from pymysql.constants import CLIENT

Expand Down
12 changes: 0 additions & 12 deletions pymysql/util.py

This file was deleted.