Skip to content

Commit

Permalink
feat: optional stdout decoding (#351)
Browse files Browse the repository at this point in the history
Do not decode stdout if the bytes cannot be represented as UTF-8.

Refs: #350

Co-authored-by: Jessica Tegner <jessica.tegner@outlook.com>
  • Loading branch information
Sofurs and JessicaTegner committed Jan 18, 2024
1 parent c28366d commit 651074e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pypandoc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,8 @@ def _convert_input(source, format, input_type, to, extra_args=(),
raise RuntimeError('Pandoc died with exitcode "%s" during conversion.' % (p.returncode))

try:
stdout = stdout.decode('utf-8')
if not (to in ["odt", "docx", "epub", "epub3", "pdf"] and outputfile == "-"):
stdout = stdout.decode('utf-8')
except UnicodeDecodeError:
# this shouldn't happen: pandoc more or less guarantees that the output is utf-8!
raise RuntimeError('Pandoc output was not utf-8.')
Expand Down

0 comments on commit 651074e

Please sign in to comment.