.. changelog::
:version: 1.0.13
+ .. change::
+ :tags: bug, py3k
+ :tickets: 3660
+
+ Fixed bug in "to_list" conversion where a single bytes object
+ would be turned into a list of individual characters. This would
+ impact among other things using the :meth:`.Query.get` method
+ on a primary key that's a bytes object.
+
.. change::
:tags: bug, orm
:tickets: 3658
from __future__ import absolute_import
import weakref
import operator
-from .compat import threading, itertools_filterfalse, string_types
+from .compat import threading, itertools_filterfalse, string_types, \
+ binary_types
from . import py2k
import types
import collections
def to_list(x, default=None):
if x is None:
return default
- if not isinstance(x, collections.Iterable) or isinstance(x, string_types):
+ if not isinstance(x, collections.Iterable) or \
+ isinstance(x, string_types + binary_types):
return [x]
elif isinstance(x, list):
return x
)
string_types = str,
+ binary_types = bytes,
binary_type = bytes
text_type = str
int_types = int,
from cStringIO import StringIO as byte_buffer
string_types = basestring,
+ binary_types = bytes,
binary_type = str
text_type = unicode
int_types = int, long
from sqlalchemy.testing.util import picklers, gc_collect
from sqlalchemy.util import classproperty, WeakSequence, get_callable_argspec
from sqlalchemy.sql import column
-from sqlalchemy.util import langhelpers
+from sqlalchemy.util import langhelpers, compat
import inspect
[1, 2, 3]
)
+ def test_from_bytes(self):
+
+ eq_(
+ util.to_list(compat.b('abc')),
+ [compat.b('abc')]
+ )
+
+ eq_(
+ util.to_list([
+ compat.b('abc'), compat.b('def')]),
+ [compat.b('abc'), compat.b('def')]
+ )
+
+
class ColumnCollectionTest(fixtures.TestBase):
def test_in(self):