mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-05 08:40:13 -04:00
py3: read in raw data files as binary
Not specifying the mode means it will be open in text mode which can munge linebreaks on some platforms and yields the wrong type of string on py3.
This commit is contained in:
parent
d50a6ddc1b
commit
d01e441905
@ -937,7 +937,7 @@ class EditMetadataAction(InterfaceAction):
|
||||
if old != prefs['read_file_metadata']:
|
||||
prefs['read_file_metadata'] = old
|
||||
if mi.cover and os.access(mi.cover, os.R_OK):
|
||||
with open(mi.cover) as f:
|
||||
with open(mi.cover, 'rb') as f:
|
||||
cdata = f.read()
|
||||
elif mi.cover_data[1] is not None:
|
||||
cdata = mi.cover_data[1]
|
||||
|
@ -461,7 +461,7 @@ class MetadataSingleDialogBase(QDialog):
|
||||
return
|
||||
cdata = None
|
||||
if mi.cover and os.access(mi.cover, os.R_OK):
|
||||
with open(mi.cover) as f:
|
||||
with open(mi.cover, 'rb') as f:
|
||||
cdata = f.read()
|
||||
elif mi.cover_data[1] is not None:
|
||||
cdata = mi.cover_data[1]
|
||||
|
@ -148,7 +148,7 @@ def load_winfonts():
|
||||
|
||||
def test_ttf_reading():
|
||||
for arg in sys.argv[1:]:
|
||||
with open(arg) as f:
|
||||
with open(arg, 'rb') as f:
|
||||
raw = f.read()
|
||||
print(os.path.basename(arg))
|
||||
get_font_characteristics(raw)
|
||||
|
Loading…
x
Reference in New Issue
Block a user