Commits

Stefan Klug committed cfac2a6

fix exception on two successive rle runs

Comments (0)

Files changed (2)

     MAX_LENGTH = 127
 
     def finish_raw():
+        if len(buf) == 0:
+            return
         result.append(len(buf)-1)
         result.extend(buf)
         buf[:] = bytearray()
 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