Convert buffer(...) -> bytes(...) for Python 3 compatibility.
authorW. Trevor King <wking@tremily.us>
Sat, 21 Jul 2012 13:07:36 +0000 (09:07 -0400)
committerW. Trevor King <wking@tremily.us>
Sat, 21 Jul 2012 13:07:36 +0000 (09:07 -0400)
igor/binarywave.py
igor/packed.py

index b172312cdacc2b60f2623def9e3f959d218ef548..ab49cddb7b60bfecc2cec437d80cc3404854e4e0 100644 (file)
@@ -82,10 +82,10 @@ class StaticStringField (_DynamicField):
                 if end > start:
                     strings.append(d[start:end])
                     if self._null_terminated:
-                        strings[-1] = strings[-1].split('\x00', 1)[0]
+                        strings[-1] = strings[-1].split(b'\x00', 1)[0]
                     start = end
         elif self._null_terminated:
-            d = d.split('\x00', 1)[0]
+            d = d.split(b'\x00', 1)[0]
         return d
 
 
index c644063feeef8a28eace33aebab136e4de6b6dfe..da773bba543634689442b197d9b71295064f8192 100644 (file)
@@ -67,7 +67,7 @@ def load(filename, strict=True, ignore_unknown=True):
         while True:
             PackedFileRecordHeader.byte_order = initial_byte_order
             PackedFileRecordHeader.setup()
-            b = buffer(f.read(PackedFileRecordHeader.size))
+            b = bytes(f.read(PackedFileRecordHeader.size))
             if not b:
                 break
             if len(b) < PackedFileRecordHeader.size:
@@ -88,7 +88,7 @@ def load(filename, strict=True, ignore_unknown=True):
                     header = PackedFileRecordHeader.unpack_from(b)
                     _LOG.debug(
                         'reordered version: {}'.format(header['version']))
-            data = buffer(f.read(header['numDataBytes']))
+            data = bytes(f.read(header['numDataBytes']))
             if len(data) < header['numDataBytes']:
                 raise ValueError(
                     ('not enough data for the next record ({} < {})'