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:
Eli Schwartz 2019-05-19 14:56:07 -04:00
parent 1ed017fabd
commit 65c0ca944b
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6

View File

@ -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