def matches(self, value): if self.hs is None or len(value.bytes) <= 1 or is_binary(value.bytes): return False try: return self.hs.spell(value.bytes.decode('utf-8')) except (UnicodeEncodeError, UnicodeDecodeError): return False
def test_is_binary(): assert is_binary(b'\0') is True assert is_binary(b'a') is False