Commits

Stefan Klug  committed cfac2a6

fix exception on two successive rle runs

  • Participants
  • Parent commits b67c3b8

Comments (0)

Files changed (2)

File src/packbits.py

     MAX_LENGTH = 127
 
     def finish_raw():
+        if len(buf) == 0:
+            return
         result.append(len(buf)-1)
         result.extend(buf)
         buf[:] = bytearray()

File test_packbits.py

 def test_encode2():
     encoded = packbits.encode(b'112112')
     assert packbits.decode(encoded) == b'112112'
+    
+def test_encode_switching_rle():
+    encoded = packbits.encode(b'1122')
+    assert packbits.decode(encoded) == b'1122'
 
 def test_encode_long_rle():
     data = b'1' * 126