We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
_skip_sync
1 parent 7da3211 commit 80cebcfCopy full SHA for 80cebcf
1 file changed
lang/py/avro/datafile.py
@@ -387,13 +387,13 @@ def _read_block_header(self) -> None:
387
388
def _skip_sync(self) -> bool:
389
"""
390
- Read the length of the sync marker; if it matches the sync marker,
391
- return True. Otherwise, seek back to where we started and return False.
+ Check if the next bytes match the sync marker.
+ If not, rewind the read position.
392
393
- proposed_sync_marker = self.reader.read(SYNC_SIZE)
394
- if proposed_sync_marker == self.sync_marker:
+ pos = self.reader.tell()
+ if self.reader.read(SYNC_SIZE) == self.sync_marker:
395
return True
396
- self.reader.seek(-SYNC_SIZE, 1)
+ self.reader.seek(pos) # Reset position if sync doesn't match
397
return False
398
399
def __next__(self) -> object:
0 commit comments