diff --git a/kaitaistruct.py b/kaitaistruct.py index 487aa4a..6457550 100644 --- a/kaitaistruct.py +++ b/kaitaistruct.py @@ -409,10 +409,11 @@ def read_bytes_full(self): def read_bytes_term(self, term, include_term, consume_term, eos_error): self.align_to_byte() + term_byte = KaitaiStream.byte_from_int(term) r = bytearray() while True: c = self._io.read(1) - if c == b'': + if not c: if eos_error: raise Exception( "end of stream reached, but no terminator %d found" % @@ -421,7 +422,7 @@ def read_bytes_term(self, term, include_term, consume_term, eos_error): return bytes(r) - if ord(c) == term: + if c == term_byte: if include_term: r += c if not consume_term: