Commits

Mikhail Korobov committed 4c17e5a

__contains__ is fixed for keys with zero bytes

  • Participants
  • Parent commits aa15750

Comments (0)

Files changed (2)

         return self.b_has_key(b_key)
 
     cpdef bint b_has_key(self, bytes key) except -1:
-        return self.dct.Contains(key)
+        return self.dct.Contains(key, len(key))
 
     cpdef bytes tobytes(self):
         """

tests/test_dawg.py

             data = [b'foo\x00bar', b'bar']
             dawg.DAWG(data)
 
+    def test_contains_with_null_bytes(self):
+        d = dawg.DAWG(['foo'])
+        assert b'foo' in d
+        assert b'foo\x00bar' not in d