]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Import from collections.abc
authorxtreak <tir.karthi@gmail.com>
Mon, 24 Sep 2018 16:23:54 +0000 (12:23 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 27 Sep 2018 19:49:18 +0000 (15:49 -0400)
Fixed additional warnings generated by Python 3.7 due to changes in the
organization of the Python ``collections`` and ``collections.abc`` packages.
Previous ``collections`` warnings were fixed in version 1.2.11. Pull request
courtesy xtreak.

See I2d1c0ef97c8ecac7af152cc56263422a40faa6bb for the original collections.abc
fixes.

Fixes: #4339
Change-Id: Ia92d2461f20309fb33ea6c6f592f7d4e7e32ae7a
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/475

doc/build/changelog/unreleased_12/4339.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/postgresql/json.py
lib/sqlalchemy/engine/result.py
lib/sqlalchemy/sql/base.py
lib/sqlalchemy/sql/sqltypes.py
test/sql/test_resultset.py

diff --git a/doc/build/changelog/unreleased_12/4339.rst b/doc/build/changelog/unreleased_12/4339.rst
new file mode 100644 (file)
index 0000000..6c963a6
--- /dev/null
@@ -0,0 +1,8 @@
+.. change::
+   :tags: bug, misc, py3k
+   :tickets: 4339
+
+   Fixed additional warnings generated by Python 3.7 due to changes in the
+   organization of the Python ``collections`` and ``collections.abc`` packages.
+   Previous ``collections`` warnings were fixed in version 1.2.11. Pull request
+   courtesy xtreak.
index 7401180300b387ca68b4975c155ea48d4d9cdb4e..1a1367f1b35135b6db6a1e7d3acf1e93a0ea443f 100644 (file)
@@ -7,7 +7,6 @@
 from __future__ import absolute_import
 
 import json
-import collections
 
 from .base import ischema_names, colspecs
 from ... import types as sqltypes
@@ -61,7 +60,7 @@ class JSONPathType(sqltypes.JSON.JSONPathType):
         super_proc = self.string_bind_processor(dialect)
 
         def process(value):
-            assert isinstance(value, collections.Sequence)
+            assert isinstance(value, util.collections_abc.Sequence)
             tokens = [util.text_type(elem)for elem in value]
             value = "{%s}" % (", ".join(tokens))
             if super_proc:
@@ -74,7 +73,7 @@ class JSONPathType(sqltypes.JSON.JSONPathType):
         super_proc = self.string_literal_processor(dialect)
 
         def process(value):
-            assert isinstance(value, collections.Sequence)
+            assert isinstance(value, util.collections_abc.Sequence)
             tokens = [util.text_type(elem)for elem in value]
             value = "{%s}" % (", ".join(tokens))
             if super_proc:
index ed6c0251d7d932de05ee8be23e0fe2d89763c51f..d4c8623757ea851bb1c40937664a633df93ef2fd 100644 (file)
@@ -179,8 +179,7 @@ class RowProxy(BaseRowProxy):
 try:
     # Register RowProxy with Sequence,
     # so sequence protocol is implemented
-    from collections import Sequence
-    Sequence.register(RowProxy)
+    util.collections_abc.Sequence.register(RowProxy)
 except ImportError:
     pass
 
index 9c79ccf7a1d15c1db1f7e983240abbea74b4eeee..5c884e1a0f56cbe197fb5dcdb3da8be683b74115 100644 (file)
@@ -14,7 +14,6 @@ from .. import util, exc
 import itertools
 from .visitors import ClauseVisitor
 import re
-import collections
 
 PARSE_AUTOCOMMIT = util.symbol('PARSE_AUTOCOMMIT')
 NO_ARG = util.symbol('NO_ARG')
@@ -46,7 +45,7 @@ def _generative(fn, *args, **kw):
     return self
 
 
-class _DialectArgView(collections.MutableMapping):
+class _DialectArgView(util.collections_abc.MutableMapping):
     """A dictionary view of dialect-level arguments in the form
     <dialectname>_<argument_name>.
 
@@ -99,7 +98,7 @@ class _DialectArgView(collections.MutableMapping):
         )
 
 
-class _DialectArgDict(collections.MutableMapping):
+class _DialectArgDict(util.collections_abc.MutableMapping):
     """A dictionary view of dialect-level arguments for a specific
     dialect.
 
index 08af78606a5acaca6a6b8cf96a132e71c662a42e..ef0de2a92c400f0fc06fb9c65d56c800ef765ae6 100644 (file)
@@ -2098,7 +2098,7 @@ class JSON(Indexable, TypeEngine):
         @util.dependencies('sqlalchemy.sql.default_comparator')
         def _setup_getitem(self, default_comparator, index):
             if not isinstance(index, util.string_types) and \
-                    isinstance(index, collections.Sequence):
+                    isinstance(index, compat.collections_abc.Sequence):
                 index = default_comparator._check_literal(
                     self.expr, operators.json_path_getitem_op,
                     index, bindparam_type=JSON.JSONPathType
index 5c7108ca09ffa537ac999ea069254751c2fdea6d..8e6279708ec4ac4819011dcc1463648eee7e461a 100644 (file)
@@ -1062,13 +1062,13 @@ class ResultProxyTest(fixtures.TablesTest):
             eq_(len(mock_rowcount.__get__.mock_calls), 2)
 
     def test_rowproxy_is_sequence(self):
-        import collections
+        from sqlalchemy.util import collections_abc
         from sqlalchemy.engine import RowProxy
 
         row = RowProxy(
             object(), ['value'], [None],
             {'key': (None, None, 0), 0: (None, None, 0)})
-        assert isinstance(row, collections.Sequence)
+        assert isinstance(row, collections_abc.Sequence)
 
     @testing.provide_metadata
     def test_rowproxy_getitem_indexes_compiled(self):