Skip to content

Commit 255b5dd

Browse files
authored
code cleanup (PyMySQL#929)
1 parent 3818ad0 commit 255b5dd

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

pymysql/connections.py

+3-12
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def __init__(
174174
sql_mode=None,
175175
read_default_file=None,
176176
conv=None,
177-
use_unicode=None,
177+
use_unicode=True,
178178
client_flag=0,
179179
cursorclass=Cursor,
180180
init_command=None,
@@ -203,9 +203,6 @@ def __init__(
203203
ssl_verify_cert=None,
204204
ssl_verify_identity=None,
205205
):
206-
if use_unicode is None and sys.version_info[0] > 2:
207-
use_unicode = True
208-
209206
if db is not None and database is None:
210207
database = db
211208
if passwd is not None and not password:
@@ -298,15 +295,9 @@ def _config(key, arg):
298295
if write_timeout is not None and write_timeout <= 0:
299296
raise ValueError("write_timeout should be > 0")
300297
self._write_timeout = write_timeout
301-
if charset:
302-
self.charset = charset
303-
self.use_unicode = True
304-
else:
305-
self.charset = DEFAULT_CHARSET
306-
self.use_unicode = False
307298

308-
if use_unicode is not None:
309-
self.use_unicode = use_unicode
299+
self.charset = charset or DEFAULT_CHARSET
300+
self.use_unicode = use_unicode
310301

311302
self.encoding = charset_by_name(self.charset).encoding
312303

pymysql/tests/test_connection.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ def testMySQLOldPasswordAuth(self):
403403
c = conn.cursor()
404404

405405
# deprecated in 5.6
406-
if sys.version_info[0:2] >= (3, 2) and self.mysql_server_is(conn, (5, 6, 0)):
406+
if self.mysql_server_is(conn, (5, 6, 0)):
407407
with self.assertWarns(pymysql.err.Warning) as cm:
408408
c.execute("SELECT OLD_PASSWORD('%s')" % db["password"])
409409
else:
@@ -420,7 +420,7 @@ def testMySQLOldPasswordAuth(self):
420420
secure_auth_setting = c.fetchone()[0]
421421
c.execute("set old_passwords=1")
422422
# pymysql.err.Warning: 'pre-4.1 password hash' is deprecated and will be removed in a future release. Please use post-4.1 password hash instead
423-
if sys.version_info[0:2] >= (3, 2) and self.mysql_server_is(conn, (5, 6, 0)):
423+
if self.mysql_server_is(conn, (5, 6, 0)):
424424
with self.assertWarns(pymysql.err.Warning) as cm:
425425
c.execute("set global secure_auth=0")
426426
else:

0 commit comments

Comments
 (0)