__init__.py
changeset 11102 cd1267c1243e
parent 10907 9ae707db5265
child 11274 d0f6fe008ec4
--- a/__init__.py	Thu Feb 11 22:00:48 2016 +0100
+++ b/__init__.py	Mon Feb 08 11:01:46 2016 +0100
@@ -34,7 +34,11 @@
 CW_SOFTWARE_ROOT = __path__[0]
 
 import sys, os, logging
-from io import BytesIO
+if (2, 7) <= sys.version_info < (2, 7, 4):
+    # http://bugs.python.org/issue10211
+    from StringIO import StringIO as BytesIO
+else:
+    from io import BytesIO
 
 from six.moves import cPickle as pickle
 
@@ -79,12 +83,14 @@
     def __init__(self, buf=b''):
         assert isinstance(buf, self._allowed_types), \
                "Binary objects must use bytes/buffer objects, not %s" % buf.__class__
-        super(Binary, self).__init__(buf)
+        # don't call super, BytesIO may be an old-style class (on python < 2.7.4)
+        BytesIO.__init__(self, buf)
 
     def write(self, data):
         assert isinstance(data, self._allowed_types), \
                "Binary objects must use bytes/buffer objects, not %s" % data.__class__
-        super(Binary, self).write(data)
+        # don't call super, BytesIO may be an old-style class (on python < 2.7.4)
+        BytesIO.write(self, data)
 
     def to_file(self, fobj):
         """write a binary to disk