diff --git a/src/rosbags/rosbag1/reader.py b/src/rosbags/rosbag1/reader.py index 5950b87f..037b65a5 100644 --- a/src/rosbags/rosbag1/reader.py +++ b/src/rosbags/rosbag1/reader.py @@ -357,7 +357,7 @@ class Reader: self.bio: Optional[BinaryIO] = None self.connections: list[Connection] = [] - self.indexes: dict[int, list[IndexData]] + self.indexes: dict[int, list[IndexData]] = {} self.index_data_header_offsets: Optional[tuple[int, int]] = None self.chunk_infos: list[ChunkInfo] = [] self.chunks: dict[int, Chunk] = {} @@ -397,6 +397,9 @@ class Reader: if index_pos == 0: raise ReaderError('Bag is not indexed, reindex before reading.') + if chunk_count == 0: + return + self.bio.seek(index_pos) try: self.connections = [self.read_connection() for _ in range(conn_count)]