Skip to content

Commit

Permalink
fix: codec error message (#902)
Browse files Browse the repository at this point in the history
Signed-off-by: 117503445 <[email protected]>
Co-authored-by: Pieter Marsman <[email protected]>
  • Loading branch information
117503445 and pietermarsman authored Jan 1, 2024
1 parent 092e477 commit 5d3386d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Resolving mediabox and pdffont ([#834](https://github.com/pdfminer/pdfminer.six/pull/834))
- Keywords that aren't terminated by the pattern `END_KEYWORD` before end-of-stream are parsed ([#885](https://github.com/pdfminer/pdfminer.six/pull/885))
- `ValueError` wrong error message when specifying codec for text output ([#902](https://github.com/pdfminer/pdfminer.six/pull/902))

## [20231228]

Expand Down
4 changes: 3 additions & 1 deletion pdfminer/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,10 @@ def __init__(
)

# write() assumes a codec for binary I/O, or no codec for text I/O.
if self.outfp_binary == (not self.codec):
if self.outfp_binary and not self.codec:
raise ValueError("Codec is required for a binary I/O output")
if not self.outfp_binary and self.codec:
raise ValueError("Codec must not be specified for a text I/O output")

if text_colors is None:
text_colors = {"char": "black"}
Expand Down

0 comments on commit 5d3386d

Please sign in to comment.