Binary initializer should accept bytearrays (closes #5084075)
authorJulien Cristau <julien.cristau@logilab.fr>
Tue, 17 Mar 2015 09:19:06 +0100
changeset 10266 813e30041a93
parent 10234 a12e4459eee5
child 10267 a8e9373faec1
Binary initializer should accept bytearrays (closes #5084075) Recent versions of pyodbc return bytearray objects for binary data.
__init__.py
--- a/__init__.py	Fri Mar 13 14:47:35 2015 +0100
+++ b/__init__.py	Tue Mar 17 09:19:06 2015 +0100
@@ -71,12 +71,12 @@
 class Binary(StringIO):
     """customize StringIO to make sure we don't use unicode"""
     def __init__(self, buf=''):
-        assert isinstance(buf, (str, buffer)), \
+        assert isinstance(buf, (str, buffer, bytearray)), \
                "Binary objects must use raw strings, not %s" % buf.__class__
         StringIO.__init__(self, buf)
 
     def write(self, data):
-        assert isinstance(data, (str, buffer)), \
+        assert isinstance(data, (str, buffer, bytearray)), \
                "Binary objects must use raw strings, not %s" % data.__class__
         StringIO.write(self, data)