]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
fix the new Binary str handling under Jython
authorPhilip Jenvey <pjenvey@underboss.org>
Wed, 9 Sep 2009 06:48:06 +0000 (06:48 +0000)
committerPhilip Jenvey <pjenvey@underboss.org>
Wed, 9 Sep 2009 06:48:06 +0000 (06:48 +0000)
lib/sqlalchemy/types.py
test/sql/test_types.py

index 8b847f201481b7769e8c7c178252aac8eab66d42..9a35e1a4af302d6ca05ed72855e58181baf675ab 100644 (file)
@@ -781,6 +781,8 @@ class Binary(TypeEngine):
     def result_processor(self, dialect):
         def process(value):
             if value is not None:
+                if util.jython and isinstance(value, array.array):
+                    value = value.tostring()
                 return str(value)
             else:
                 return None
@@ -852,11 +854,7 @@ class PickleType(MutableType, TypeDecorator):
         # Py3K
         #return loads(value)
         # Py2K
-        if util.jython and isinstance(value, array.ArrayType):
-            value = value.tostring()
-        else:
-            value = str(value)
-        return loads(value)
+        return loads(str(value))
         # end Py2K
 
     def copy_value(self, value):
index f57347115e706e4764b6f843a75f2257d989280e..c844cf696e4f8cec9625c32ee1d5ad20ee227b53 100644 (file)
@@ -406,20 +406,6 @@ class BinaryTest(TestBase, AssertsExecutionResults):
                 typemap={'pickled':PickleType, 'mypickle':MyPickleType, 'data':Binary, 'data_slice':Binary}, 
                 bind=testing.db)
         ):
-            #if util.jython:
-                # TODO: may need to modify Binary type directly
-                # to detect jython if something other than str()/bytes()
-                # is needed to convert from raw to string/bytes.
-                # ArrayType should no longer be expected here though.
-                # users who want raw ArrayType can of course create their
-                # own BinaryType that does no conversion.
-                #_eq_data = eq_data
-                #def eq_data(x, y):
-                #    # Jython currently returns arrays
-                #    from array import ArrayType
-                #    if isinstance(y, ArrayType):
-                #        return eq_(x, y.tostring())
-                #    return _eq_data(x, y)
             l = stmt.execute().fetchall()
             eq_(stream1, l[0]['data'])
             eq_(stream1[0:100], l[0]['data_slice'])