Skip to content

Commit

Permalink
Fixed weird way for detecting big/little endian platforms.
Browse files Browse the repository at this point in the history
  • Loading branch information
gryf committed Jun 25, 2021
1 parent 47d9fda commit dc6a5f9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ebook_converter/ebooks/lrf/lrfparser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import array
import itertools
import re
import sys

from ebook_converter.utils.config import OptionParser
from ebook_converter.utils.filenames import ascii_filename
Expand Down Expand Up @@ -41,11 +42,11 @@ def parse(self):
def _parse_objects(self):
self.objects = {}
self._file.seek(self.object_index_offset)
obj_array = array.array("I",
self._file.read(4 * 4 *
self.number_of_objects))
if ord(array.array("i", [1]).tostring()[0:1]) == 0: # big-endian
obj_array = array.array("I", self._file.read(4 * 4 *
self.number_of_objects))
if sys.byteorder == 'big':
obj_array.byteswap()

for i in range(self.number_of_objects):
if not self.keep_parsing:
break
Expand Down

0 comments on commit dc6a5f9

Please sign in to comment.