[Python-modules-commits] [mysql-connector-python] 01/02: Import mysql-connector-python_2.1.6.orig.tar.gz

Sandro Tosi morph at moszumanska.debian.org
Tue May 2 02:13:22 UTC 2017


This is an automated email from the git hooks/post-receive script.

morph pushed a commit to branch master
in repository mysql-connector-python.

commit e4a2edc66b9a87b99371279da763d989a1f7a578
Author: Sandro Tosi <morph at debian.org>
Date:   Sun Apr 30 20:50:38 2017 -0400

    Import mysql-connector-python_2.1.6.orig.tar.gz
---
 CHANGES.txt                                  |  14 +-
 PKG-INFO                                     |   4 +-
 README.txt                                   |   4 +-
 lib/cpy_distutils.py                         |  54 ++++---
 lib/mysql/connector/abstracts.py             |  11 +-
 lib/mysql/connector/connection.py            |  14 +-
 lib/mysql/connector/connection_cext.py       |  12 +-
 lib/mysql/connector/constants.py             |   4 +-
 lib/mysql/connector/cursor.py                |  25 ++--
 lib/mysql/connector/cursor_cext.py           |  15 +-
 lib/mysql/connector/django/introspection.py  |   5 +-
 lib/mysql/connector/django/operations.py     |  20 ++-
 lib/mysql/connector/errors.py                |   3 +-
 lib/mysql/connector/fabric/__init__.py       |  20 +--
 lib/mysql/connector/fabric/caching.py        |  20 +--
 lib/mysql/connector/fabric/connection.py     |  57 ++++----
 lib/mysql/connector/locales/__init__.py      |   3 +-
 lib/mysql/connector/network.py               |  10 +-
 lib/mysql/connector/pooling.py               |  15 +-
 lib/mysql/connector/protocol.py              |  14 +-
 lib/mysql/connector/version.py               |   4 +-
 setupinfo.py                                 |   8 +-
 src/mysql_capi.c                             |  34 ++++-
 tests/cext/test_cext_api.py                  |   2 +
 tests/cext/test_cext_cursor.py               |  25 +++-
 tests/data/ssl/tests_CA_cert.pem             |  35 +++--
 tests/data/ssl/tests_CA_key.pem              |  50 +++----
 tests/data/ssl/tests_client_cert.pem         |  77 ++++++++--
 tests/data/ssl/tests_client_key.pem          |  50 +++----
 tests/data/ssl/tests_expired_server_cert.pem |  68 +++++++++
 tests/data/ssl/tests_expired_server_key.pem  |  27 ++++
 tests/data/ssl/tests_server_cert.pem         |  77 ++++++++--
 tests/data/ssl/tests_server_key.pem          |  50 +++----
 tests/mysqld.py                              |  37 +++--
 tests/test_abstracts.py                      |  10 +-
 tests/test_bugs.py                           | 204 ++++++++++++++++++++++++++-
 tests/test_django.py                         | 103 +++++++++++---
 tests/test_setup.py                          |   5 +-
 unittests.py                                 |  17 ++-
 39 files changed, 899 insertions(+), 308 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 18112d1..6e2c797 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -3,11 +3,23 @@ MySQL Connector/Python 2.1 - Release Notes & Changes
 ====================================================
 
 MySQL Connector/Python
-Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
+Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
 
 Full release notes:
  http://dev.mysql.com/doc/relnotes/connector-python/en/
 
+v2.1.6
+======
+
+- BUG#25726671: Fix compatibility issues with the latest Django versions
+- BUG#25558885: Set default connection timeout to pure connector/python
+- BUG#25397650: Verify server certificate only if ssl_verify_cert is True
+- BUG#25589496: Don't convert to unicode if non-ascii data is present
+- BUG#25383644: Add connection back to pool on exception
+- BUG#22476689: Importing world.sql fails with cext enabled
+- BUG#20736339: Expect multiple include directories from mysql_config
+- BUG#19685386: C extension tests are failing using MySQL 5.7.4
+
 v2.1.5
 ======
 
diff --git a/PKG-INFO b/PKG-INFO
index 4af4d6f..9ab448d 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: mysql-connector-python
-Version: 2.1.5
+Version: 2.1.6
 Summary: MySQL driver written in Python
 Home-page: http://dev.mysql.com/doc/connector-python/en/index.html
 Author: Oracle and/or its affiliates
@@ -27,6 +27,8 @@ Classifier: Programming Language :: Python :: 3
 Classifier: Programming Language :: Python :: 3.1
 Classifier: Programming Language :: Python :: 3.2
 Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
 Classifier: Topic :: Database
 Classifier: Topic :: Software Development
 Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
diff --git a/README.txt b/README.txt
index 773af0b..46cce18 100644
--- a/README.txt
+++ b/README.txt
@@ -3,7 +3,7 @@ MySQL Connector/Python 2.1
 ==========================
 
 MySQL Connector/Python
-Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
+Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
 
 License information can be found in the LICENSE.txt file.
 
@@ -28,7 +28,7 @@ doubt, this particular copy of the software is released
 under the version 2 of the GNU General Public License.
 MySQL Connector/Python is brought to you by Oracle.
 
-Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
 
 License information can be found in the LICENSE.txt file.
 
diff --git a/lib/cpy_distutils.py b/lib/cpy_distutils.py
index e944ce6..04741ea 100644
--- a/lib/cpy_distutils.py
+++ b/lib/cpy_distutils.py
@@ -1,5 +1,5 @@
 # MySQL Connector/Python - MySQL driver written in Python.
-# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
 
 # MySQL Connector/Python is licensed under the terms of the GPLv2
 # <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -136,21 +136,7 @@ def unix_lib_is64bit(lib_file):
     return False
 
 
-def get_mysql_config_info(mysql_config):
-    """Get MySQL information using mysql_config tool
-
-    Returns a dict.
-    """
-    options = ['cflags', 'include', 'libs', 'libs_r', 'plugindir', 'version']
-
-    cmd = [mysql_config] + [ "--{0}".format(opt) for opt in options ]
-
-    try:
-        proc = Popen(cmd, stdout=PIPE, universal_newlines=True)
-        stdout, _ = proc.communicate()
-    except OSError as exc:
-        raise DistutilsExecError("Failed executing mysql_config: {0}".format(
-            str(exc)))
+def parse_mysql_config_info(options, stdout):
     log.debug("# stdout: {0}".format(stdout))
     info = {}
     for option, line in zip(options, stdout.split('\n')):
@@ -173,7 +159,28 @@ def get_mysql_config_info(mysql_config):
     info['lib_r_dir'] = libs[0].replace('-L', '')
     info['libs_r'] = [ lib.replace('-l', '') for lib in libs[1:] ]
 
-    info['include'] = info['include'].replace('-I', '')
+    info['include'] = [x.strip() for x in info['include'].split('-I')[1:]]
+
+    return info
+
+
+def get_mysql_config_info(mysql_config):
+    """Get MySQL information using mysql_config tool
+
+    Returns a dict.
+    """
+    options = ['cflags', 'include', 'libs', 'libs_r', 'plugindir', 'version']
+
+    cmd = [mysql_config] + [ "--{0}".format(opt) for opt in options ]
+
+    try:
+        proc = Popen(cmd, stdout=PIPE, universal_newlines=True)
+        stdout, _ = proc.communicate()
+    except OSError as exc:
+        raise DistutilsExecError("Failed executing mysql_config: {0}".format(
+            str(exc)))
+
+    info = parse_mysql_config_info(options, stdout)
 
     # Try to figure out the architecture
     info['arch'] = None
@@ -316,7 +323,7 @@ class BuildExtDynamic(build_ext):
                 else:
                     raise OSError("Unsupported platform: %s" % os.name)
 
-                include_dir = os.path.join(connc_loc, 'include')
+                include_dirs = [os.path.join(connc_loc, 'include')]
                 if os.name == 'nt':
                     libraries = ['libmysql']
                 else:
@@ -341,19 +348,20 @@ class BuildExtDynamic(build_ext):
                 log.error(err_version)
                 sys.exit(1)
 
-            include_dir = myc_info['include']
+            include_dirs = myc_info['include']
             libraries = myc_info['libs']
             library_dirs = myc_info['lib_dir']
             self._mysql_config_info = myc_info
             self.arch = self._mysql_config_info['arch']
             connc_64bit = self.arch == 'x86_64'
 
-        if not os.path.exists(include_dir):
-            log.error(err_invalid_loc, connc_loc)
-            sys.exit(1)
+        for include_dir in include_dirs:
+            if not os.path.exists(include_dir):
+                log.error(err_invalid_loc, connc_loc)
+                sys.exit(1)
 
         # Set up the build_ext class
-        self.include_dirs.append(include_dir)
+        self.include_dirs.extend(include_dirs)
         self.libraries.extend(libraries)
         self.library_dirs.append(library_dirs)
 
diff --git a/lib/mysql/connector/abstracts.py b/lib/mysql/connector/abstracts.py
index c83a527..928bd8c 100644
--- a/lib/mysql/connector/abstracts.py
+++ b/lib/mysql/connector/abstracts.py
@@ -1,5 +1,5 @@
 # MySQL Connector/Python - MySQL driver written in Python.
-# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
 
 # MySQL Connector/Python is licensed under the terms of the GPLv2
 # <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -62,7 +62,7 @@ class MySQLConnectionAbstract(object):
         self._use_unicode = True
         self._get_warnings = False
         self._raise_on_warnings = False
-        self._connection_timeout = None
+        self._connection_timeout = DEFAULT_CONFIGURATION["connect_timeout"]
         self._buffered = False
         self._unread_result = False
         self._have_next_result = False
@@ -231,6 +231,13 @@ class MySQLConnectionAbstract(object):
         except KeyError:
             self._consume_results = False
 
+        # Configure auth_plugin
+        try:
+            self._auth_plugin = config['auth_plugin']
+            del config['auth_plugin']
+        except KeyError:
+            self._auth_plugin = ''
+
         # Configure character set and collation
         if 'charset' in config or 'collation' in config:
             try:
diff --git a/lib/mysql/connector/connection.py b/lib/mysql/connector/connection.py
index 453c73e..ebf0c38 100644
--- a/lib/mysql/connector/connection.py
+++ b/lib/mysql/connector/connection.py
@@ -1,5 +1,5 @@
 # MySQL Connector/Python - MySQL driver written in Python.
-# Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
 
 # MySQL Connector/Python is licensed under the terms of the GPLv2
 # <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -78,7 +78,6 @@ class MySQLConnection(MySQLConnectionAbstract):
         self._use_unicode = True
         self._get_warnings = False
         self._raise_on_warnings = False
-        self._connection_timeout = None
         self._buffered = False
         self._unread_result = False
         self._have_next_result = False
@@ -184,6 +183,7 @@ class MySQLConnection(MySQLConnectionAbstract):
 
         Returns subclass of MySQLBaseSocket.
         """
+        # pylint: disable=R0204
         conn = None
         if self.unix_socket and os.name != 'nt':
             conn = MySQLUnixSocket(unix_socket=self.unix_socket)
@@ -191,6 +191,7 @@ class MySQLConnection(MySQLConnectionAbstract):
             conn = MySQLTCPSocket(host=self.server_host,
                                   port=self.server_port,
                                   force_ipv6=self._force_ipv6)
+        # pylint: enable=R0204
         conn.set_connection_timeout(self._connection_timeout)
         return conn
 
@@ -440,14 +441,17 @@ class MySQLConnection(MySQLConnectionAbstract):
                 rows = self._protocol.read_binary_result(
                     self._socket, columns, count)
             else:
-                rows = self._protocol.read_text_result(self._socket, self._server_version, count=count)
+                rows = self._protocol.read_text_result(self._socket,
+                                                       self._server_version,
+                                                       count=count)
         except errors.Error as err:
             self.unread_result = False
             raise err
 
         if rows[-1] is not None:
-            ek = rows[-1] # OK or EOF
-            self._handle_server_status(ek['status_flag'] if 'status_flag' in ek else ek['server_status'])
+            row = rows[-1]  # OK or EOF
+            self._handle_server_status(row['status_flag'] if 'status_flag' in
+                                       row else row['server_status'])
             self.unread_result = False
 
         return rows
diff --git a/lib/mysql/connector/connection_cext.py b/lib/mysql/connector/connection_cext.py
index 9c00a9a..cf29c3b 100644
--- a/lib/mysql/connector/connection_cext.py
+++ b/lib/mysql/connector/connection_cext.py
@@ -1,5 +1,5 @@
 # MySQL Connector/Python - MySQL driver written in Python.
-# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
 
 # MySQL Connector/Python is licensed under the terms of the GPLv2
 # <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -54,6 +54,7 @@ else:
     HAVE_CMYSQL = True
 # pylint: enable=F0401,C0413
 
+
 class CMySQLConnection(MySQLConnectionAbstract):
 
     """Class initiating a MySQL Connection using Connector/C"""
@@ -64,7 +65,6 @@ class CMySQLConnection(MySQLConnectionAbstract):
             raise RuntimeError(
                 "MySQL Connector/Python C Extension not available")
         self._cmysql = None
-        self._connection_timeout = 2
         self._columns = []
         self.converter = None
         super(CMySQLConnection, self).__init__(**kwargs)
@@ -139,12 +139,11 @@ class CMySQLConnection(MySQLConnectionAbstract):
 
     def _open_connection(self):
         charset_name = CharacterSet.get_info(self._charset_id)[0]
-
-        self._cmysql = _mysql_connector.MySQL(
+        self._cmysql = _mysql_connector.MySQL(  # pylint: disable=E1101
             buffered=self._buffered,
             raw=self._raw,
             charset_name=charset_name,
-            connection_timeout=int(self._connection_timeout or 10),
+            connection_timeout=(self._connection_timeout or 0),
             use_unicode=self._use_unicode,
             auth_plugin=self._auth_plugin)
 
@@ -260,6 +259,7 @@ class CMySQLConnection(MySQLConnectionAbstract):
             raise AttributeError("count should be 1 or higher, or None")
 
         counter = 0
+        # pylint: disable=R0204
         try:
             row = self._cmysql.fetch_row()
             while row:
@@ -278,7 +278,7 @@ class CMySQLConnection(MySQLConnectionAbstract):
             self.free_result()
             raise errors.get_mysql_exception(msg=exc.msg, errno=exc.errno,
                                              sqlstate=exc.sqlstate)
-
+        # pylint: enable=R0204
         return rows
 
     def get_row(self, binary=False, columns=None):
diff --git a/lib/mysql/connector/constants.py b/lib/mysql/connector/constants.py
index 8d27cb0..709e675 100644
--- a/lib/mysql/connector/constants.py
+++ b/lib/mysql/connector/constants.py
@@ -1,5 +1,5 @@
 # MySQL Connector/Python - MySQL driver written in Python.
-# Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
 
 # MySQL Connector/Python is licensed under the terms of the GPLv2
 # <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -686,7 +686,7 @@ class CharacterSet(_Constants):
         return tuple(res)
 
 
-class SQLMode(_Constants):  # pylint: disable=R0921
+class SQLMode(_Constants):
     """MySQL SQL Modes
 
     The numeric values of SQL Modes are not interesting, only the names
diff --git a/lib/mysql/connector/cursor.py b/lib/mysql/connector/cursor.py
index 09b7b54..3002192 100644
--- a/lib/mysql/connector/cursor.py
+++ b/lib/mysql/connector/cursor.py
@@ -1,5 +1,5 @@
 # MySQL Connector/Python - MySQL driver written in Python.
-# Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
 
 # MySQL Connector/Python is licensed under the terms of the GPLv2
 # <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -41,7 +41,7 @@ RE_SQL_ON_DUPLICATE = re.compile(
     re.I | re.M | re.S)
 RE_SQL_INSERT_STMT = re.compile(
     r"({0}|\s)*INSERT({0}|\s)*INTO\s+[`'\"]?.+[`'\"]?(?:\.[`'\"]?.+[`'\"]?)"
-     "{{0,2}}\s+VALUES\s*\(.+(?:\s*,.+)*\)".format(SQL_COMMENT),
+    r"{{0,2}}\s+VALUES\s*\(.+(?:\s*,.+)*\)".format(SQL_COMMENT),
     re.I | re.M | re.S)
 RE_SQL_INSERT_VALUES = re.compile(r'.*VALUES\s*(\(.*\)).*', re.I | re.M | re.S)
 RE_PY_PARAM = re.compile(b'(%s)')
@@ -97,20 +97,27 @@ def _bytestr_format_dict(bytestr, value_dict):
     b'x=%(y)s y=%(x)s'
     """
     def replace(matchobj):
+        """Replace pattern."""
         value = None
         groups = matchobj.groupdict()
         if groups["conversion_type"] == b"%":
             value = b"%"
         if groups["conversion_type"] == b"s":
-            key = groups["mapping_key"].encode("utf-8") \
-                  if PY2 else groups["mapping_key"]
+            key = groups["mapping_key"]
             value = value_dict[key]
         if value is None:
             raise ValueError("Unsupported conversion_type: {0}"
                              "".format(groups["conversion_type"]))
-        return value.decode("utf-8") if PY2 else value
-    return RE_PY_MAPPING_PARAM.sub(replace, bytestr.decode("utf-8")
-                                   if PY2 else bytestr)
+        return bytes(value) if PY2 else value
+
+    stmt = RE_PY_MAPPING_PARAM.sub(replace, bytestr)
+    if PY2:
+        try:
+            return stmt.decode("utf-8")
+        except UnicodeDecodeError:
+            pass
+    return stmt
+
 
 class CursorBase(MySQLCursorAbstract):
     """
@@ -749,10 +756,12 @@ class MySQLCursor(CursorBase):
             can_consume_results = self._connection._consume_results
             for result in self._connection.cmd_query_iter(call):
                 self._connection._consume_results = False
+                # pylint: disable=R0204
                 if self._raw:
                     tmp = MySQLCursorBufferedRaw(self._connection._get_self())
                 else:
                     tmp = MySQLCursorBuffered(self._connection._get_self())
+                # pylint: enable=R0204
                 tmp._executed = "(a result of {0})".format(call)
                 tmp._handle_result(result)
                 if tmp._warnings is not None:
@@ -760,7 +769,7 @@ class MySQLCursor(CursorBase):
                 if 'columns' in result:
                     results.append(tmp)
             self._connection._consume_results = can_consume_results
-            #pylint: enable=W0212
+            # pylint: enable=W0212
 
             if argnames:
                 select = "SELECT {0}".format(','.join(argtypes))
diff --git a/lib/mysql/connector/cursor_cext.py b/lib/mysql/connector/cursor_cext.py
index 4dd6e9a..df5fed3 100644
--- a/lib/mysql/connector/cursor_cext.py
+++ b/lib/mysql/connector/cursor_cext.py
@@ -1,5 +1,5 @@
 # MySQL Connector/Python - MySQL driver written in Python.
-# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
 
 # MySQL Connector/Python is licensed under the terms of the GPLv2
 # <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -28,6 +28,8 @@ from collections import namedtuple
 import re
 import weakref
 
+from _mysql_connector import MySQLInterfaceError  # pylint: disable=F0401,E0611
+
 from .abstracts import MySQLConnectionAbstract, MySQLCursorAbstract
 from .catch23 import PY2, isunicode
 from . import errors
@@ -39,7 +41,6 @@ from .cursor import (
     RE_SQL_SPLIT_STMTS
 )
 
-from _mysql_connector import MySQLInterfaceError  # pylint: disable=F0401
 
 class _ParamSubstitutor(object):
 
@@ -204,7 +205,10 @@ class CMySQLCursor(MySQLCursorAbstract):
                 if exc.errno != CR_NO_RESULT_SET:
                     raise
             i += 1
-            self._executed = executed_list[i].strip()
+            try:
+                self._executed = executed_list[i].strip()
+            except IndexError:
+                self._executed = executed_list[0]
             yield self
         return
 
@@ -429,14 +433,14 @@ class CMySQLCursor(MySQLCursorAbstract):
             results = []
             while self._cnx.result_set_available:
                 result = self._cnx.fetch_eof_columns()
-                # pylint: disable=W0212
+                # pylint: disable=W0212,R0204
                 if self._raw:
                     cur = CMySQLCursorBufferedRaw(self._cnx._get_self())
                 else:
                     cur = CMySQLCursorBuffered(self._cnx._get_self())
                 cur._executed = "(a result of {0})".format(call)
                 cur._handle_result(result)
-                # pylint: enable=W0212
+                # pylint: enable=W0212,R0204
                 results.append(cur)
                 self._cnx.next_result()
             self._stored_results = results
@@ -807,4 +811,3 @@ class CMySQLCursorPrepared(CMySQLCursor):
         super(CMySQLCursorPrepared, self).__init__(connection)
         raise NotImplementedError(
             "Alternative: Use connection.MySQLCursorPrepared")
-
diff --git a/lib/mysql/connector/django/introspection.py b/lib/mysql/connector/django/introspection.py
index 77e5503..35b3018 100644
--- a/lib/mysql/connector/django/introspection.py
+++ b/lib/mysql/connector/django/introspection.py
@@ -279,9 +279,8 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
                     'unique': False,
                     'index': False,
                     'check': False,
-                    'foreign_key': (
-                        (ref_table, ref_column) if ref_column else None,
-                    )
+                    'foreign_key': \
+                        (ref_table, ref_column) if ref_column else None
                 }
             constraints[constraint]['columns'].add(column)
         # Now get the constraint types
diff --git a/lib/mysql/connector/django/operations.py b/lib/mysql/connector/django/operations.py
index 127750d..8b23290 100644
--- a/lib/mysql/connector/django/operations.py
+++ b/lib/mysql/connector/django/operations.py
@@ -185,6 +185,10 @@ class DatabaseOperations(BaseDatabaseOperations):
                              'value for AutoField.')
         return value
 
+    if django.VERSION > (1, 8):
+        def adapt_datetimefield_value(self, value):
+            return self.value_to_db_datetime(value)
+
     def value_to_db_datetime(self, value):
         if value is None:
             return None
@@ -202,6 +206,10 @@ class DatabaseOperations(BaseDatabaseOperations):
             return datetime_to_mysql(value)
         return self.connection.converter.to_mysql(value)
 
+    if django.VERSION > (1, 8):
+        def adapt_timefield_value(self, value):
+            return self.value_to_db_time(value)
+
     def value_to_db_time(self, value):
         if value is None:
             return None
@@ -218,9 +226,15 @@ class DatabaseOperations(BaseDatabaseOperations):
     def max_name_length(self):
         return 64
 
-    def bulk_insert_sql(self, fields, num_values):
-        items_sql = "({0})".format(", ".join(["%s"] * len(fields)))
-        return "VALUES " + ", ".join([items_sql] * num_values)
+    if django.VERSION < (1, 9):
+        def bulk_insert_sql(self, fields, num_values):
+            items_sql = "({0})".format(", ".join(["%s"] * len(fields)))
+            return "VALUES " + ", ".join([items_sql] * num_values)
+    else:
+        def bulk_insert_sql(self, fields, placeholder_rows):
+            placeholder_rows_sql = (", ".join(row) for row in placeholder_rows)
+            values_sql = ", ".join("({0})".format(sql) for sql in placeholder_rows_sql)
+            return "VALUES " + values_sql
 
     if django.VERSION < (1, 8):
         def year_lookup_bounds(self, value):
diff --git a/lib/mysql/connector/errors.py b/lib/mysql/connector/errors.py
index ea354f2..d2eedfb 100644
--- a/lib/mysql/connector/errors.py
+++ b/lib/mysql/connector/errors.py
@@ -1,5 +1,5 @@
 # MySQL Connector/Python - MySQL driver written in Python.
-# Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
 
 # MySQL Connector/Python is licensed under the terms of the GPLv2
 # <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -301,4 +301,5 @@ _ERROR_EXCEPTIONS = {
     2049: NotSupportedError,
     2055: OperationalError,
     2061: InterfaceError,
+    2026: InterfaceError,
 }
diff --git a/lib/mysql/connector/fabric/__init__.py b/lib/mysql/connector/fabric/__init__.py
index b3d6a06..c88fe03 100644
--- a/lib/mysql/connector/fabric/__init__.py
+++ b/lib/mysql/connector/fabric/__init__.py
@@ -1,5 +1,5 @@
 # MySQL Connector/Python - MySQL driver written in Python.
-# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
 
 # MySQL Connector/Python is licensed under the terms of the GPLv2
 # <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -26,6 +26,15 @@
 
 from collections import namedtuple
 
+from .connection import (
+    MODE_READONLY, MODE_READWRITE,
+    STATUS_PRIMARY, STATUS_SECONDARY,
+    SCOPE_GLOBAL, SCOPE_LOCAL,
+    Fabric, FabricConnection,
+    MySQLFabricConnection,
+    FabricSet,
+)
+
 # Order of field_names must match how Fabric is returning the data
 FabricMySQLServer = namedtuple(
     'FabricMySQLServer',
@@ -39,15 +48,6 @@ FabricShard = namedtuple(
      'shard', 'shard_type', 'group', 'global_group']
     )
 
-from .connection import (
-    MODE_READONLY, MODE_READWRITE,
-    STATUS_PRIMARY, STATUS_SECONDARY,
-    SCOPE_GLOBAL, SCOPE_LOCAL,
-    Fabric, FabricConnection,
-    MySQLFabricConnection,
-    FabricSet,
-)
-
 
 def connect(**kwargs):
     """Create a MySQLFabricConnection object"""
diff --git a/lib/mysql/connector/fabric/caching.py b/lib/mysql/connector/fabric/caching.py
index a24d6b1..9073498 100644
--- a/lib/mysql/connector/fabric/caching.py
+++ b/lib/mysql/connector/fabric/caching.py
@@ -1,5 +1,5 @@
 # MySQL Connector/Python - MySQL driver written in Python.
-# Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
 
 # MySQL Connector/Python is licensed under the terms of the GPLv2
 # <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -116,32 +116,33 @@ class CacheShardTable(CacheEntry):
     def add_partition(self, key, group):
         """Add sharding information for a group"""
         if self.shard_type == 'RANGE':
-            key = int(key)
+            _key = int(key)
         elif self.shard_type == 'RANGE_DATETIME':
             try:
                 if ':' in key:
-                    key = datetime.strptime(key, "%Y-%m-%d %H:%M:%S")
+                    # pylint: disable=R0204
+                    _key = datetime.strptime(key, "%Y-%m-%d %H:%M:%S")
                 else:
-                    key = datetime.strptime(key, "%Y-%m-%d").date()
+                    _key = datetime.strptime(key, "%Y-%m-%d").date()
             except:
                 raise ValueError(
                     "RANGE_DATETIME key could not be parsed, was: {0}".format(
                         key
                     ))
         elif self.shard_type == 'RANGE_STRING':
-            pass
+            _key = key
         elif self.shard_type == "HASH":
-            pass
+            _key = key
         else:
             raise ValueError("Unsupported sharding type {0}".format(
                 self.shard_type
             ))
-        self.partitioning[key] = {
+        self.partitioning[_key] = {
             'group': group,
         }
         self.reset_ttl()
-        bisect.insort_right(self.keys, key)
-        insort_right_rev(self.keys_reversed, key)
+        bisect.insort_right(self.keys, _key)
+        insort_right_rev(self.keys_reversed, _key)
 
     @classmethod
     def hash_index(cls, part1, part2=None):
@@ -175,6 +176,7 @@ class CacheGroup(CacheEntry):
             group=self.group_name,
         )
 
+
 class FabricCache(object):
     """Singleton class for caching Fabric data
 
diff --git a/lib/mysql/connector/fabric/connection.py b/lib/mysql/connector/fabric/connection.py
index 44da175..7e2f657 100644
--- a/lib/mysql/connector/fabric/connection.py
+++ b/lib/mysql/connector/fabric/connection.py
@@ -1,5 +1,5 @@
 # MySQL Connector/Python - MySQL driver written in Python.
-# Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
 
 # MySQL Connector/Python is licensed under the terms of the GPLv2
 # <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -27,13 +27,34 @@ import sys
 import datetime
 import time
 import uuid
-from base64 import b16decode
-from bisect import bisect
-from hashlib import md5
 import logging
 import socket
 import collections
 
+from base64 import b16decode
+from bisect import bisect
+from hashlib import md5
+
+import mysql.connector
+
+from ..connection import MySQLConnection
+from ..conversion import MySQLConverter
+from ..pooling import MySQLConnectionPool
+from ..errors import (
+    Error, InterfaceError, NotSupportedError, MySQLFabricError, InternalError,
+    DatabaseError
+)
+from ..cursor import (
+    MySQLCursor, MySQLCursorBuffered,
+    MySQLCursorRaw, MySQLCursorBufferedRaw
+)
+from .. import errorcode
+from . import FabricMySQLServer, FabricShard
+from .caching import FabricCache
+from .balancing import WeightedRoundRobin
+from .. import version
+from ..catch23 import PY2, isunicode, UNICODE_TYPES
+
 # pylint: disable=F0401,E0611
 try:
     from xmlrpclib import Fault, ServerProxy, Transport
@@ -47,7 +68,7 @@ except ImportError:
 
 if sys.version_info[0] == 2:
     try:
-        from httplib import HTTPSConnection
+        from httplib import HTTPSConnection  # pylint: disable=C0412
     except ImportError:
         HAVE_SSL = False
     else:
@@ -59,26 +80,7 @@ else:
         HAVE_SSL = False
     else:
         HAVE_SSL = True
-# pylint: enable=F0401,E0611
 
-import mysql.connector
-from ..connection import MySQLConnection
-from ..conversion import MySQLConverter
-from ..pooling import MySQLConnectionPool
-from ..errors import (
-    Error, InterfaceError, NotSupportedError, MySQLFabricError, InternalError,
-    DatabaseError
-)
-from ..cursor import (
-    MySQLCursor, MySQLCursorBuffered,
-    MySQLCursorRaw, MySQLCursorBufferedRaw
-)
-from .. import errorcode
-from . import FabricMySQLServer, FabricShard
-from .caching import FabricCache
-from .balancing import WeightedRoundRobin
-from .. import version
-from ..catch23 import PY2, isunicode, UNICODE_TYPES
 
 RESET_CACHE_ON_ERROR = (
     errorcode.CR_SERVER_LOST,
@@ -213,8 +215,7 @@ class MySQLRPCProtocol(object):
             kwargs = self._process_params_dict(kwargs)
             params.extend(kwargs)
 
-        params = ', '.join(params)
-        return params
+        return ', '.join(params)
 
     def execute(self, group, command, *args, **kwargs):
         """Executes the given command with MySQL protocol
@@ -460,7 +461,7 @@ if HAVE_SSL:
             if PY2:
                 urllib2.HTTPSHandler.__init__(self)
             else:
-                super().__init__()  # pylint: disable=W0104
+                super().__init__()  # pylint: disable=W0104,E1004
             self._ssl_config = ssl_config
 
         def https_open(self, req):
@@ -488,7 +489,7 @@ class FabricTransport(Transport):
         if PY2:
             Transport.__init__(self, use_datetime=False)
         else:
-            super().__init__(use_datetime=False)
+            super().__init__(use_datetime=False)  # pylint: disable=E1004
         self._username = username
         self._password = password
         self._use_datetime = use_datetime
diff --git a/lib/mysql/connector/locales/__init__.py b/lib/mysql/connector/locales/__init__.py
index ad784e6..cd5e54f 100644
--- a/lib/mysql/connector/locales/__init__.py
+++ b/lib/mysql/connector/locales/__init__.py
@@ -1,5 +1,5 @@
 # MySQL Connector/Python - MySQL driver written in Python.
-# Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
 
 # MySQL Connector/Python is licensed under the terms of the GPLv2
 # <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -68,4 +68,3 @@ def get_client_error(error, language='eng'):
             return None
 
     raise ValueError("error argument needs to be either an integer or string")
-
diff --git a/lib/mysql/connector/network.py b/lib/mysql/connector/network.py
index 1ef55a3..7c097b7 100644
--- a/lib/mysql/connector/network.py
+++ b/lib/mysql/connector/network.py
@@ -1,5 +1,5 @@
 # MySQL Connector/Python - MySQL driver written in Python.
-# Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
 
 # MySQL Connector/Python is licensed under the terms of the GPLv2
 # <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -168,9 +168,9 @@ class BaseMySQLSocket(object):
                 tmpbuf = bytearray()
                 for pkt in pkts:
                     tmpbuf += pkt
-                tmpbuf = buffer(tmpbuf)  # pylint: disable=E0602
+                tmpbuf = buffer(tmpbuf)  # pylint: disable=E0602,R0204
             else:
-                tmpbuf = b''.join(pkts)
+                tmpbuf = b''.join(pkts)  # pylint: disable=R0204
             del pkts
             zbuf = zlib.compress(tmpbuf[:16384])
             header = (struct.pack('<I', len(zbuf))[0:3]
@@ -181,7 +181,7 @@ class BaseMySQLSocket(object):
             zpkts.append(header + zbuf)
             tmpbuf = tmpbuf[16384:]
             pllen = len(tmpbuf)
-            self.next_compressed_packet_number
+            self.next_compressed_packet_number  # pylint: disable=W0104
             while pllen > maxpktlen:
                 zbuf = zlib.compress(tmpbuf[:maxpktlen])
                 header = (struct.pack('<I', len(zbuf))[0:3]
@@ -192,7 +192,7 @@ class BaseMySQLSocket(object):
                 zpkts.append(header + zbuf)
                 tmpbuf = tmpbuf[maxpktlen:]
                 pllen = len(tmpbuf)
-                self.next_compressed_packet_number
+                self.next_compressed_packet_number  # pylint: disable=W0104
             if tmpbuf:
                 zbuf = zlib.compress(tmpbuf)
                 header = (struct.pack('<I', len(zbuf))[0:3]
diff --git a/lib/mysql/connector/pooling.py b/lib/mysql/connector/pooling.py
index 17d2f59..b671120 100644
--- a/lib/mysql/connector/pooling.py
+++ b/lib/mysql/connector/pooling.py
@@ -1,5 +1,5 @@
 # MySQL Connector/Python - MySQL driver written in Python.
-# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
 
 # MySQL Connector/Python is licensed under the terms of the GPLv2
 # <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -112,12 +112,13 @@ class PooledMySQLConnection(object):
         When the pool is configured to reset the session, the session
         state will be cleared by re-authenticating the user.
         """
-        cnx = self._cnx
-        if self._cnx_pool.reset_session:
-            cnx.reset_session()
-
-        self._cnx_pool.add_connection(cnx)
-        self._cnx = None
+        try:
+            cnx = self._cnx
+            if self._cnx_pool.reset_session:
+                cnx.reset_session()
+        finally:
+            self._cnx_pool.add_connection(cnx)
+            self._cnx = None
 
     def config(self, **kwargs):
         """Configuration is done through the pool"""
diff --git a/lib/mysql/connector/protocol.py b/lib/mysql/connector/protocol.py
index 6c75a0a..9014897 100644
--- a/lib/mysql/connector/protocol.py
+++ b/lib/mysql/connector/protocol.py
@@ -1,5 +1,5 @@
 # MySQL Connector/Python - MySQL driver written in Python.
-# Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
 
 # MySQL Connector/Python is licensed under the terms of the GPLv2
 # <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -29,7 +29,7 @@ import datetime
 from decimal import Decimal
 
 from .constants import (
-    FieldFlag, ServerCmd, FieldType, ClientFlag, MAX_MYSQL_TABLE_COLUMNS)
+    FieldFlag, ServerCmd, FieldType, ClientFlag)
 from . import errors, utils
 from .authentication import get_auth_plugin
 from .catch23 import PY2, struct_unpack
@@ -61,7 +61,7 @@ class MySQLProtocol(object):
                 ssl_enabled=ssl_enabled)
             plugin_auth_response = auth.auth_response()
         except (TypeError, errors.InterfaceError) as exc:
-            raise errors.ProgrammingError(
+            raise errors.InterfaceError(
                 "Failed authentication: {0}".format(str(exc)))
 
         if client_flags & ClientFlag.SECURE_CONNECTION:
@@ -90,7 +90,7 @@ class MySQLProtocol(object):
             username_bytes = username.encode('utf8')  # pylint: disable=E1103
         except AttributeError:
             # Username is already bytes
-            username_bytes = username
+            username_bytes = username  # pylint: disable=R0204
         packet = struct.pack('<IIB{filler}{usrlen}sx'.format(
             filler='x' * 23, usrlen=len(username_bytes)),
                              client_flags, max_allowed_packet, charset,
@@ -141,7 +141,7 @@ class MySQLProtocol(object):
             username_bytes = username.encode('utf8')  # pylint: disable=E1103
         except AttributeError:
             # Username is already bytes
-            username_bytes = username
+            username_bytes = username  # pylint: disable=R0204
         packet = struct.pack('<B{usrlen}sx'.format(usrlen=len(username_bytes)),
                              ServerCmd.CHANGE_USER, username_bytes)
 
@@ -328,7 +328,7 @@ class MySQLProtocol(object):
                     packet = sock.recv()
                 datas.append(packet[4:])
                 rowdata = utils.read_lc_string_list(bytearray(b'').join(datas))
-            elif (packet[4] == 254 and packet[0] < 7):
+            elif packet[4] == 254 and packet[0] < 7:
                 eof = self.parse_eof(packet)
                 rowdata = None
             else:
@@ -385,7 +385,7 @@ class MySQLProtocol(object):
             mcs = 0
             if length == 11:
                 mcs = struct_unpack('I', packet[8:length + 1])[0]
-            value = datetime.datetime(
+            value = datetime.datetime(  # pylint: disable=R0204
                 year=struct_unpack('H', packet[1:3])[0],
                 month=packet[3],
                 day=packet[4],
diff --git a/lib/mysql/connector/version.py b/lib/mysql/connector/version.py
index a3c311c..f6b49d5 100644
--- a/lib/mysql/connector/version.py
+++ b/lib/mysql/connector/version.py
@@ -1,5 +1,5 @@
 # MySQL Connector/Python - MySQL driver written in Python.
-# Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
 
 # MySQL Connector/Python is licensed under the terms of the GPLv2
 # <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -26,7 +26,7 @@ The file version.py gets installed and is available after installation
 as mysql.connector.version.
 """
 
-VERSION = (2, 1, 5, '', 0)
+VERSION = (2, 1, 6, '', 0)
 
 if VERSION[3] and VERSION[4]:
     VERSION_TEXT = '{0}.{1}.{2}{3}{4}'.format(*VERSION)
diff --git a/setupinfo.py b/setupinfo.py
index 6784a38..18998ae 100644
--- a/setupinfo.py
+++ b/setupinfo.py
@@ -1,5 +1,5 @@
 # MySQL Connector/Python - MySQL driver written in Python.
-# Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
... 1286 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/mysql-connector-python.git



More information about the Python-modules-commits mailing list