[Python-modules-commits] [python-mysqldb] 01/04: Import python-mysqldb_1.3.6.orig.tar.gz
Brian May
bam at moszumanska.debian.org
Thu Oct 22 10:25:34 UTC 2015
This is an automated email from the git hooks/post-receive script.
bam pushed a commit to branch master
in repository python-mysqldb.
commit edd00306fb9cf2547197f4e04fb4ca4a29836a96
Author: Brian May <bam at debian.org>
Date: Thu Oct 22 18:20:50 2015 +1100
Import python-mysqldb_1.3.6.orig.tar.gz
---
HISTORY | 28 ++++++++++++++++++++++++++
MySQLdb/connections.py | 2 --
MySQLdb/converters.py | 36 +++++++++++++++-------------------
MySQLdb/cursors.py | 41 +++++++++++++++++++--------------------
MySQLdb/release.py | 4 ++--
MySQLdb/times.py | 24 +++++++++++++----------
PKG-INFO | 4 ++--
_mysql.c | 2 +-
doc/FAQ.rst | 2 +-
doc/user_guide.rst | 2 +-
metadata.cfg | 6 +++---
mysqlclient.egg-info/PKG-INFO | 4 ++--
mysqlclient.egg-info/SOURCES.txt | 1 +
mysqlclient.egg-info/pbr.json | 1 +
setup.cfg | 2 +-
tests/test_MySQLdb_nonstandard.py | 6 ++++++
16 files changed, 99 insertions(+), 66 deletions(-)
diff --git a/HISTORY b/HISTORY
index 19d53c9..58ff35e 100644
--- a/HISTORY
+++ b/HISTORY
@@ -1,4 +1,32 @@
=====================
+ What's new in 1.3.6
+=====================
+
+Fix escape_string() doesn't work.
+
+Remove `Cursor.__del__` to fix uncollectable circular reference on Python 3.3.
+
+Add context manager support to `Cursor`. It automatically closes cursor on `__exit__`.
+
+.. code-block::
+
+ with conn.cursor() as cur:
+ cur.execute("SELECT 1+1")
+ print(cur.fetchone())
+ # cur is now closed
+
+
+=====================
+ What's new in 1.3.5
+=====================
+
+Fix TINYBLOB, MEDIUMBLOB and LONGBLOB are treated as string and decoded
+to unicode or cause UnicodeError.
+
+Fix aware datetime is formatted with timezone offset (e.g. "+0900").
+
+
+=====================
What's new in 1.3.4
=====================
diff --git a/MySQLdb/connections.py b/MySQLdb/connections.py
index 828c364..a84896e 100644
--- a/MySQLdb/connections.py
+++ b/MySQLdb/connections.py
@@ -17,7 +17,6 @@ import re
def defaulterrorhandler(connection, cursor, errorclass, errorvalue):
"""
-
If cursor is not None, (errorclass, errorvalue) is appended to
cursor.messages; otherwise it is appended to
connection.messages. Then errorclass is raised with errorvalue as
@@ -25,7 +24,6 @@ def defaulterrorhandler(connection, cursor, errorclass, errorvalue):
You can override this with your own error handler by assigning it
to the instance.
-
"""
error = errorclass, errorvalue
if cursor:
diff --git a/MySQLdb/converters.py b/MySQLdb/converters.py
index 9937e25..8a9908d 100644
--- a/MySQLdb/converters.py
+++ b/MySQLdb/converters.py
@@ -17,7 +17,7 @@ Key: Python type object (from types) or class
Conversion function:
- Arguments: Python object of indicated type or class AND
+ Arguments: Python object of indicated type or class AND
conversion dictionary
Returns: SQL literal value
@@ -46,10 +46,6 @@ try:
except AttributeError:
ArrayType = array.array
-try:
- set
-except NameError:
- from sets import Set as set
def Bool2Str(s, d): return str(int(s))
@@ -58,7 +54,7 @@ def Str2Set(s):
def Set2Str(s, d):
return string_literal(','.join(s), d)
-
+
def Thing2Str(s, d):
"""Convert something into a string via str()."""
return str(s)
@@ -74,7 +70,7 @@ def Float2Str(o, d):
def None2NULL(o, d):
"""Convert None to NULL."""
- return NULL # duh
+ return NULL # duh
def Thing2Literal(o, d):
"""Convert something into a SQL string literal. If using
@@ -93,6 +89,9 @@ def array2Str(o, d):
def quote_tuple(t, d):
return "(%s)" % (','.join(escape_sequence(t, d)))
+# bytes or str regarding to BINARY_FLAG.
+_bytes_or_str = [(FLAG.BINARY, bytes)]
+
conversions = {
int: Thing2Str,
long: Thing2Str,
@@ -123,19 +122,16 @@ conversions = {
FIELD_TYPE.DATETIME: DateTime_or_None,
FIELD_TYPE.TIME: TimeDelta_or_None,
FIELD_TYPE.DATE: Date_or_None,
- FIELD_TYPE.BLOB: [
- (FLAG.BINARY, bytes),
- ],
- FIELD_TYPE.STRING: [
- (FLAG.BINARY, bytes),
- ],
- FIELD_TYPE.VAR_STRING: [
- (FLAG.BINARY, bytes),
- ],
- FIELD_TYPE.VARCHAR: [
- (FLAG.BINARY, bytes),
- ],
- }
+
+ FIELD_TYPE.TINY_BLOB: _bytes_or_str,
+ FIELD_TYPE.MEDIUM_BLOB: _bytes_or_str,
+ FIELD_TYPE.LONG_BLOB: _bytes_or_str,
+ FIELD_TYPE.BLOB: _bytes_or_str,
+ FIELD_TYPE.STRING: _bytes_or_str,
+ FIELD_TYPE.VAR_STRING: _bytes_or_str,
+ FIELD_TYPE.VARCHAR: _bytes_or_str,
+}
+
if PY2:
conversions[unicode] = Unicode2Str
else:
diff --git a/MySQLdb/cursors.py b/MySQLdb/cursors.py
index a781695..d177f20 100644
--- a/MySQLdb/cursors.py
+++ b/MySQLdb/cursors.py
@@ -44,7 +44,6 @@ from _mysql_exceptions import Warning, Error, InterfaceError, DataError, \
class BaseCursor(object):
-
"""A base for Cursor classes. Useful attributes:
description
@@ -59,7 +58,6 @@ class BaseCursor(object):
arraysize
default number of rows fetchmany() will fetch
-
"""
from _mysql_exceptions import MySQLError, Warning, Error, InterfaceError, \
@@ -85,17 +83,24 @@ class BaseCursor(object):
self._info = None
self.rownumber = None
- def __del__(self):
- self.close()
- self.errorhandler = None
- self._result = None
-
def close(self):
"""Close the cursor. No further queries will be possible."""
- if self.connection is None or self.connection() is None:
- return
- while self.nextset(): pass
- self.connection = None
+ try:
+ if self.connection is None or self.connection() is None:
+ return
+ while self.nextset():
+ pass
+ finally:
+ self.connection = None
+ self.errorhandler = None
+ self._result = None
+
+ def __enter__(self):
+ return self
+
+ def __exit__(self, *exc_info):
+ del exc_info
+ self.close()
def _check_executed(self):
if not self._executed:
@@ -124,7 +129,7 @@ class BaseCursor(object):
if self._executed:
self.fetchall()
del self.messages[:]
-
+
db = self._get_db()
nr = db.next_result()
if nr == -1:
@@ -135,7 +140,7 @@ class BaseCursor(object):
return 1
def _post_get_result(self): pass
-
+
def _do_get_result(self):
db = self._get_db()
self._result = self._get_result()
@@ -162,7 +167,6 @@ class BaseCursor(object):
return con
def execute(self, query, args=None):
-
"""Execute a query.
query -- string, query to execute on server
@@ -173,9 +177,9 @@ class BaseCursor(object):
%(key)s must be used as the placeholder.
Returns long integer rows affected, if any
-
"""
- del self.messages[:]
+ while self.nextset():
+ pass
db = self._get_db()
# NOTE:
@@ -206,23 +210,19 @@ class BaseCursor(object):
except TypeError as m:
if m.args[0] in ("not enough arguments for format string",
"not all arguments converted"):
- self.messages.append((ProgrammingError, m.args[0]))
self.errorhandler(self, ProgrammingError, m.args[0])
else:
- self.messages.append((TypeError, m))
self.errorhandler(self, TypeError, m)
except (SystemExit, KeyboardInterrupt):
raise
except:
exc, value = sys.exc_info()[:2]
- self.messages.append((exc, value))
self.errorhandler(self, exc, value)
self._executed = query
if not self._defer_warnings: self._warning_check()
return r
def executemany(self, query, args):
-
"""Execute a multi-row query.
query -- string, query to execute on server
@@ -237,7 +237,6 @@ class BaseCursor(object):
This method improves performance on multiple-row INSERT and
REPLACE. Otherwise it is equivalent to looping over args with
execute().
-
"""
del self.messages[:]
db = self._get_db()
diff --git a/MySQLdb/release.py b/MySQLdb/release.py
index f4d8ff5..5e2c51c 100644
--- a/MySQLdb/release.py
+++ b/MySQLdb/release.py
@@ -1,4 +1,4 @@
__author__ = "Andy Dustman <farcepest at gmail.com>"
-version_info = (1,3,4,'final',1)
-__version__ = "1.3.4"
+version_info = (1,3,6,'final',1)
+__version__ = "1.3.6"
diff --git a/MySQLdb/times.py b/MySQLdb/times.py
index 85dfbd7..f28c7a6 100644
--- a/MySQLdb/times.py
+++ b/MySQLdb/times.py
@@ -2,9 +2,8 @@
This module provides some Date and Time classes for dealing with MySQL data.
-Use Python datetime module to handle date and time columns."""
-
-import math
+Use Python datetime module to handle date and time columns.
+"""
from time import localtime
from datetime import date, datetime, time, timedelta
from _mysql import string_literal
@@ -33,12 +32,19 @@ format_TIME = format_DATE = str
def format_TIMEDELTA(v):
seconds = int(v.seconds) % 60
- minutes = int(v.seconds / 60) % 60
- hours = int(v.seconds / 3600) % 24
+ minutes = int(v.seconds // 60) % 60
+ hours = int(v.seconds // 3600) % 24
return '%d %d:%d:%d' % (v.days, hours, minutes, seconds)
def format_TIMESTAMP(d):
- return d.isoformat(" ")
+ """
+ :type d: datetime.datetime
+ """
+ if d.microsecond:
+ fmt = "{0.year:04}-{0.month:02}-{0.day:02} {0.hour:02}:{0.minute:02}:{0.second:02}.{0.microsecond:06}"
+ else:
+ fmt = "{0.year:04}-{0.month:02}-{0.day:02} {0.hour:02}:{0.minute:02}:{0.second:02}"
+ return fmt.format(d)
def DateTime_or_None(s):
@@ -102,14 +108,12 @@ def Time_or_None(s):
def Date_or_None(s):
try:
return date(*[ int(x) for x in s.split('-',2)])
- except (SystemExit, KeyboardInterrupt):
- raise
- except:
+ except (TypeError, ValueError):
return None
def DateTime2literal(d, c):
"""Format a DateTime object as an ISO timestamp."""
- return string_literal(format_TIMESTAMP(d),c)
+ return string_literal(format_TIMESTAMP(d), c)
def DateTimeDelta2literal(d, c):
"""Format a DateTimeDelta object as a time."""
diff --git a/PKG-INFO b/PKG-INFO
index d26e7c3..066bd91 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: mysqlclient
-Version: 1.3.4
+Version: 1.3.6
Summary: Python interface to MySQL
Home-page: https://github.com/PyMySQL/mysqlclient-python
Author: INADA Naoki
@@ -28,7 +28,7 @@ Description:
.. _MySQL: http://www.mysql.com/
.. _`Free Software`: http://www.gnu.org/
- .. [PEP-0249] http://www.python.org/peps/pep-0249.html
+ .. [PEP-0249] https://www.python.org/dev/peps/pep-0249/
Platform: ALL
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Other Environment
diff --git a/_mysql.c b/_mysql.c
index 1e7b70a..a479b4b 100644
--- a/_mysql.c
+++ b/_mysql.c
@@ -1079,7 +1079,7 @@ _mysql_escape_string(
PyObject *str;
char *in, *out;
int len, size;
- if (!PyArg_ParseTuple(args, "y#:escape_string", &in, &size)) return NULL;
+ if (!PyArg_ParseTuple(args, "s#:escape_string", &in, &size)) return NULL;
str = PyBytes_FromStringAndSize((char *) NULL, size*2+1);
if (!str) return PyErr_NoMemory();
out = PyBytes_AS_STRING(str);
diff --git a/doc/FAQ.rst b/doc/FAQ.rst
index b6a4ce9..79e828a 100644
--- a/doc/FAQ.rst
+++ b/doc/FAQ.rst
@@ -139,5 +139,5 @@ Other Resources
* Read `PEP-249`_
-.. _`PEP-249`: http://www.python.org/peps/pep-0249.html
+.. _`PEP-249`: https://www.python.org/dev/peps/pep-0249/
diff --git a/doc/user_guide.rst b/doc/user_guide.rst
index fbc86e5..232870a 100644
--- a/doc/user_guide.rst
+++ b/doc/user_guide.rst
@@ -167,7 +167,7 @@ exceptions are defined in a separate module, ``_mysql_exceptions``,
but ``_mysql`` exports them. Read DB API specification PEP-249_ to
find out what they are, or you can use the catch-all ``MySQLError``.
-.. _PEP-249: http://www.python.org/peps/pep-0249.html
+.. _PEP-249: https://www.python.org/dev/peps/pep-0249/
At this point your query has been executed and you need to get the
results. You have two options::
diff --git a/metadata.cfg b/metadata.cfg
index 813fd62..504ddbe 100644
--- a/metadata.cfg
+++ b/metadata.cfg
@@ -1,6 +1,6 @@
[metadata]
-version: 1.3.4
-version_info: (1,3,4,'final',1)
+version: 1.3.6
+version_info: (1,3,6,'final',1)
description: Python interface to MySQL
long_description:
=========================
@@ -24,7 +24,7 @@ long_description:
\n
.. _MySQL: http://www.mysql.com/
.. _`Free Software`: http://www.gnu.org/
- .. [PEP-0249] http://www.python.org/peps/pep-0249.html
+ .. [PEP-0249] https://www.python.org/dev/peps/pep-0249/
author: Andy Dustman
author_email: farcepest at gmail.com
maintainer: INADA Naoki
diff --git a/mysqlclient.egg-info/PKG-INFO b/mysqlclient.egg-info/PKG-INFO
index d26e7c3..066bd91 100644
--- a/mysqlclient.egg-info/PKG-INFO
+++ b/mysqlclient.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: mysqlclient
-Version: 1.3.4
+Version: 1.3.6
Summary: Python interface to MySQL
Home-page: https://github.com/PyMySQL/mysqlclient-python
Author: INADA Naoki
@@ -28,7 +28,7 @@ Description:
.. _MySQL: http://www.mysql.com/
.. _`Free Software`: http://www.gnu.org/
- .. [PEP-0249] http://www.python.org/peps/pep-0249.html
+ .. [PEP-0249] https://www.python.org/dev/peps/pep-0249/
Platform: ALL
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Other Environment
diff --git a/mysqlclient.egg-info/SOURCES.txt b/mysqlclient.egg-info/SOURCES.txt
index 6367994..2990d64 100644
--- a/mysqlclient.egg-info/SOURCES.txt
+++ b/mysqlclient.egg-info/SOURCES.txt
@@ -38,6 +38,7 @@ doc/user_guide.rst
mysqlclient.egg-info/PKG-INFO
mysqlclient.egg-info/SOURCES.txt
mysqlclient.egg-info/dependency_links.txt
+mysqlclient.egg-info/pbr.json
mysqlclient.egg-info/top_level.txt
tests/capabilities.py
tests/configdb.py
diff --git a/mysqlclient.egg-info/pbr.json b/mysqlclient.egg-info/pbr.json
new file mode 100644
index 0000000..2064d35
--- /dev/null
+++ b/mysqlclient.egg-info/pbr.json
@@ -0,0 +1 @@
+{"is_release": false, "git_version": "4481bdb"}
\ No newline at end of file
diff --git a/setup.cfg b/setup.cfg
index 66d419f..b3b2f5a 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -12,7 +12,7 @@ requires = python
build-requires = python-devel mysql-devel zlib-devel openssl-devel
[egg_info]
-tag_build =
tag_date = 0
+tag_build =
tag_svn_revision = 0
diff --git a/tests/test_MySQLdb_nonstandard.py b/tests/test_MySQLdb_nonstandard.py
index a5c0e84..d92b260 100644
--- a/tests/test_MySQLdb_nonstandard.py
+++ b/tests/test_MySQLdb_nonstandard.py
@@ -41,6 +41,12 @@ class CoreModule(unittest.TestCase):
def test_thread_safe(self):
self.assertTrue(isinstance(_mysql.thread_safe(), int))
+ def test_escape_string(self):
+ self.assertEqual(_mysql.escape_string(b'foo"bar'),
+ b'foo\\"bar', "escape byte string")
+ self.assertEqual(_mysql.escape_string(u'foo"bar'),
+ b'foo\\"bar', "escape unicode string")
+
class CoreAPI(unittest.TestCase):
"""Test _mysql interaction internals."""
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-mysqldb.git
More information about the Python-modules-commits
mailing list