@@ -410,11 +410,11 @@ def _parse_metadata(self) -> None:
410410
411411 def _process_page_meta (self ) -> bool :
412412 self ._read_page_header ()
413- pt = [ const .page_meta_type , const .page_amd_type ] + const .page_mix_types
413+ pt = const .page_meta_types + [ const .page_amd_type , const .page_mix_type ]
414414 if self ._current_page_type in pt :
415415 self ._process_page_metadata ()
416- is_data_page = self ._current_page_type & const .page_data_type
417- is_mix_page = self ._current_page_type in const .page_mix_types
416+ is_data_page = self ._current_page_type == const .page_data_type
417+ is_mix_page = self ._current_page_type == const .page_mix_type
418418 return bool (
419419 is_data_page
420420 or is_mix_page
@@ -424,7 +424,9 @@ def _process_page_meta(self) -> bool:
424424 def _read_page_header (self ):
425425 bit_offset = self ._page_bit_offset
426426 tx = const .page_type_offset + bit_offset
427- self ._current_page_type = self ._read_int (tx , const .page_type_length )
427+ self ._current_page_type = (
428+ self ._read_int (tx , const .page_type_length ) & const .page_type_mask2
429+ )
428430 tx = const .block_count_offset + bit_offset
429431 self ._current_page_block_count = self ._read_int (tx , const .block_count_length )
430432 tx = const .subheader_count_offset + bit_offset
@@ -774,13 +776,13 @@ def _read_next_page(self):
774776 raise ValueError (msg )
775777
776778 self ._read_page_header ()
777- page_type = self ._current_page_type
778- if page_type == const .page_meta_type :
779+ if self ._current_page_type in const .page_meta_types :
779780 self ._process_page_metadata ()
780781
781- is_data_page = page_type & const .page_data_type
782- pt = [const .page_meta_type ] + const .page_mix_types
783- if not is_data_page and self ._current_page_type not in pt :
782+ if self ._current_page_type not in const .page_meta_types + [
783+ const .page_data_type ,
784+ const .page_mix_type ,
785+ ]:
784786 return self ._read_next_page ()
785787
786788 return False
0 commit comments