mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
py3: make pml input work
Opening a file in binary mode in python3 returns a BufferedReader which does not have an encoding attribute. Assume in this case it is functionally equivalent to None. I'm not sure when pml_stream.encoding will ever equal anything, since even on python2 the attribute exists but is None when opening files in binary mode... which we explicitly do. So I'm not sure why this ever checks the existing encoding. Possibly when the input plugin is given a file opened in text mode, not raw mode? in that case, it may be wrong to always decode it when reading.
This commit is contained in:
parent
1ed017fabd
commit
65c0ca944b
@ -41,7 +41,9 @@ class PMLInput(InputFormatPlugin):
|
|||||||
else:
|
else:
|
||||||
html_stream = html_path
|
html_stream = html_path
|
||||||
|
|
||||||
ienc = pml_stream.encoding if pml_stream.encoding else 'cp1252'
|
ienc = getattr(pml_stream, 'encoding', None)
|
||||||
|
if ienc is None:
|
||||||
|
ienc = 'cp1252'
|
||||||
if self.options.input_encoding:
|
if self.options.input_encoding:
|
||||||
ienc = self.options.input_encoding
|
ienc = self.options.input_encoding
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user