Skip to content

Commit

Permalink
MAINT: Remove unreachable code in read_block_backwards (#1250)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthew Peveler <matt.peveler@gmail.com>
  • Loading branch information
MartinThoma and MasterOdin authored Aug 19, 2022
1 parent cb6c224 commit 52463ea
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions PyPDF2/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,11 @@ def read_until_regex(


def read_block_backwards(stream: StreamType, to_read: int) -> bytes:
"""Given a stream at position X, read a block of size
to_read ending at position X.
The stream's position should be unchanged.
"""
Given a stream at position X, read a block of size to_read ending at position X.
This changes the stream's position to the beginning of where the block was
read.
"""
if stream.tell() < to_read:
raise PdfStreamError("Could not read malformed PDF file")
Expand All @@ -177,8 +179,6 @@ def read_block_backwards(stream: StreamType, to_read: int) -> bytes:
read = stream.read(to_read)
# Seek to the start of the block we read after reading it.
stream.seek(-to_read, SEEK_CUR)
if len(read) != to_read:
raise PdfStreamError(f"EOF: read {len(read)}, expected {to_read}?")
return read


Expand Down

0 comments on commit 52463ea

Please sign in to comment.