Skip to content

Commit

Permalink
decode
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinThoma committed Apr 24, 2022
1 parent c2df916 commit 7126544
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion PyPDF2/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1835,7 +1835,7 @@ def read(self, stream):
stream.seek(0, 0)
header_byte = stream.read(5)
if header_byte != b"%PDF-":
raise PdfReadError("PDF starts with {}, but '%PDF-' expected".format(header_byte))
raise PdfReadError("PDF starts with {}, but '%PDF-' expected".format(header_byte.decode("utf8")))
stream.seek(-1, 2)
last1M = stream.tell() - 1024 * 1024 + 1 # offset of last MB of stream
line = b_('')
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def test_read_empty():
def test_read_malformed_header():
with pytest.raises(PdfReadError) as exc:
PdfFileReader(io.BytesIO(b"foo"))
assert exc.value.args[0] == "PDF starts with b'foo', but '%PDF-' expected"
assert exc.value.args[0] == "PDF starts with 'foo', but '%PDF-' expected"


def test_read_malformed_body():
Expand Down

0 comments on commit 7126544

Please sign in to comment.