Skip to content

Commit f427d5a

Browse files
committed
Merge pull request #413 from PyMySQL/release/0.7
Release/0.7
2 parents 0b25a72 + eb01869 commit f427d5a

File tree

8 files changed

+42
-30
lines changed

8 files changed

+42
-30
lines changed

CHANGELOG

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Changes
22

3+
## 0.7
4+
5+
Release date: 2016-01-10
6+
7+
Notable changes:
8+
9+
* Faster binary escaping
10+
* Add `"_binary" prefix` to string literal for binary types.
11+
binary types are: `bytearray` on Python 2, `bytes` and `bytearray` on Python 3.
12+
This is because recent MySQL show warnings when string literal is invalid for
13+
connection encoding.
14+
* `pymysql.Binary()` returns `bytearray` on Python 2. This is required to distinguish
15+
binary and string.
16+
* Auth plugin support.
17+
* no_delay option is ignored. It will be removed in PyMySQL 0.8.
18+
19+
320
## 0.6.7
421

522
Release date: 2015-09-30

pymysql/__init__.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
'''
1+
"""
22
PyMySQL: A pure-Python MySQL client library.
33
4-
Copyright (c) 2010, 2013 PyMySQL contributors
4+
Copyright (c) 2010-2016 PyMySQL contributors
55
66
Permission is hereby granted, free of charge, to any person obtaining a copy
77
of this software and associated documentation files (the "Software"), to deal
@@ -20,12 +20,10 @@
2020
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2121
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
THE SOFTWARE.
23+
"""
24+
import sys
2325

24-
'''
25-
26-
VERSION = (0, 6, 7, None)
27-
28-
from ._compat import text_type, JYTHON, IRONPYTHON, PY2
26+
from ._compat import PY2
2927
from .constants import FIELD_TYPE
3028
from .converters import escape_dict, escape_sequence, escape_string
3129
from .err import Warning, Error, InterfaceError, DataError, \
@@ -34,15 +32,14 @@
3432
from .times import Date, Time, Timestamp, \
3533
DateFromTicks, TimeFromTicks, TimestampFromTicks
3634

37-
import sys
38-
3935

36+
VERSION = (0, 7, 0, None)
4037
threadsafety = 1
4138
apilevel = "2.0"
42-
paramstyle = "format"
39+
paramstyle = "pyformat"
4340

44-
class DBAPISet(frozenset):
4541

42+
class DBAPISet(frozenset):
4643

4744
def __ne__(self, other):
4845
if isinstance(other, set):
@@ -73,15 +70,15 @@ def __hash__(self):
7370
DATETIME = TIMESTAMP
7471
ROWID = DBAPISet()
7572

73+
7674
def Binary(x):
7775
"""Return x as a binary type."""
78-
if isinstance(x, text_type) and not (JYTHON or IRONPYTHON):
79-
x = x.encode()
8076
if PY2:
8177
return bytearray(x)
8278
else:
8379
return bytes(x)
8480

81+
8582
def Connect(*args, **kwargs):
8683
"""
8784
Connect to the database; see connections.Connection.__init__() for
@@ -92,11 +89,10 @@ def Connect(*args, **kwargs):
9289

9390
from pymysql import connections as _orig_conn
9491
if _orig_conn.Connection.__init__.__doc__ is not None:
95-
Connect.__doc__ = _orig_conn.Connection.__init__.__doc__ + ("""
96-
See connections.Connection.__init__() for information about defaults.
97-
""")
92+
Connect.__doc__ = _orig_conn.Connection.__init__.__doc__
9893
del _orig_conn
9994

95+
10096
def get_client_info(): # for MySQLdb compatibility
10197
return '.'.join(map(str, VERSION))
10298

@@ -110,7 +106,7 @@ def get_client_info(): # for MySQLdb compatibility
110106
__version__ = get_client_info()
111107

112108
def thread_safe():
113-
return True # match MySQLdb.thread_safe()
109+
return True # match MySQLdb.thread_safe()
114110

115111
def install_as_MySQLdb():
116112
"""
@@ -119,6 +115,7 @@ def install_as_MySQLdb():
119115
"""
120116
sys.modules["MySQLdb"] = sys.modules["_mysql"] = sys.modules["pymysql"]
121117

118+
122119
__all__ = [
123120
'BINARY', 'Binary', 'Connect', 'Connection', 'DATE', 'Date',
124121
'Time', 'Timestamp', 'DateFromTicks', 'TimeFromTicks', 'TimestampFromTicks',
@@ -131,6 +128,5 @@ def install_as_MySQLdb():
131128
'paramstyle', 'threadsafety', 'version_info',
132129

133130
"install_as_MySQLdb",
134-
135-
"NULL","__version__",
136-
]
131+
"NULL", "__version__",
132+
]

pymysql/connections.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,6 @@ class Connection(object):
521521
522522
The proper way to get an instance of this class is to call
523523
connect().
524-
525524
"""
526525

527526
socket = None

pymysql/tests/test_connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import datetime
2-
import decimal
32
import sys
43
import time
54
import unittest2
65
import pymysql
76
from pymysql.tests import base
7+
from pymysql._compat import text_type
88

99

1010
class TempUser:
@@ -534,7 +534,7 @@ def test_escape_fallback_encoder(self):
534534
class Custom(str):
535535
pass
536536

537-
mapping = {pymysql.text_type: pymysql.escape_string}
537+
mapping = {text_type: pymysql.escape_string}
538538
self.assertEqual(con.escape(Custom('foobar'), mapping), "'foobar'")
539539

540540
def test_escape_no_default(self):

pymysql/tests/thirdparty/test_MySQLdb/capabilities.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def setUp(self):
3232
self.BLOBUText = unicode().join(unichr(i) for i in range(16834))
3333
else:
3434
self.BLOBUText = "".join(chr(i) for i in range(16834))
35-
self.BLOBBinary = self.db_module.Binary(''.join([chr(i) for i in range(256)] * 16))
35+
data = bytearray(range(256)) * 16
36+
self.BLOBBinary = self.db_module.Binary(data)
3637

3738
leak_test = True
3839

pymysql/tests/thirdparty/test_MySQLdb/dbapi20.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,8 +827,8 @@ def test_Timestamp(self):
827827
# self.assertEqual(str(t1),str(t2))
828828

829829
def test_Binary(self):
830-
b = self.driver.Binary('Something')
831-
b = self.driver.Binary('')
830+
b = self.driver.Binary(b'Something')
831+
b = self.driver.Binary(b'')
832832

833833
def test_STRING(self):
834834
self.assertTrue(hasattr(self.driver,'STRING'),

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ universal = 1
44
[flake8]
55
ignore = E226,E301,E701
66
exclude = tests,build
7-
max-line-length = 99
7+
max-line-length = 119

setup.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@
1616
author_email='yutaka.matsubara@gmail.com',
1717
maintainer='INADA Naoki',
1818
maintainer_email='songofacandy@gmail.com',
19-
description='Pure-Python MySQL Driver',
19+
description='Pure Python MySQL Driver',
2020
license="MIT",
2121
packages=find_packages(),
2222
classifiers=[
2323
'Programming Language :: Python :: 2',
24-
'Programming Language :: Python :: 2.6',
2524
'Programming Language :: Python :: 2.7',
2625
'Programming Language :: Python :: 3',
2726
'Programming Language :: Python :: 3.3',
@@ -33,5 +32,5 @@
3332
'Intended Audience :: Developers',
3433
'License :: OSI Approved :: MIT License',
3534
'Topic :: Database',
36-
]
35+
],
3736
)

0 commit comments

Comments
 (0)