Commits

Lenard Lindstrom committed b988a37

Fix Python 3.x issues with unit tests

  • Participants
  • Parent commits 6bf8a4e

Comments (0)

Files changed (2)

File test/bufferproxy_test.py

         exp = array.BufferExporter((10,), 'B', readonly=True)
         b = BufferProxy(exp)
         self.assertEqual(b.length, exp.len)
-        self.assertEqual(b.raw, string_at(exp.buf, exp.len).encode('latin_1'))
+        self.assertEqual(b.raw, string_at(exp.buf, exp.len))
         d = b.__array_interface__
         try:
             self.assertEqual(d['typestr'], '|u1')

File test/test_utils/array.py

 import sys
 import ctypes
 import operator
+try:
+    reduce
+except NameError:
+    from functools import reduce
 
 __all__ = ["BufferExporter", "BufferImporter"]
 
     @property
     def format(self):
         """return bytes or None for NULL field"""
-        return ctypes.cast(self._view.format, ctypes.c_char_p).value
+        format_addr = self._view.format
+        if format_addr is None:
+            return None
+        return ctypes.cast(format_addr, ctypes.c_char_p).value.decode('ascii')
     @property
     def itemsize(self):
         """return int"""