Skip to content

MAINT: Remove unreachable code in read_block_backwards#1250

Merged
MartinThoma merged 3 commits into
mainfrom
remove-dead-code-utils-read-backwards
Aug 19, 2022
Merged

MAINT: Remove unreachable code in read_block_backwards#1250
MartinThoma merged 3 commits into
mainfrom
remove-dead-code-utils-read-backwards

Conversation

@MartinThoma

@MartinThoma MartinThoma commented Aug 18, 2022

Copy link
Copy Markdown
Member

I think that part is dead code, because it's prevented by stream.tell() < to_read

@codecov

codecov Bot commented Aug 18, 2022

Copy link
Copy Markdown

Codecov Report

Merging #1250 (dcfee7e) into main (cb6c224) will increase coverage by 0.03%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #1250      +/-   ##
==========================================
+ Coverage   94.67%   94.71%   +0.03%     
==========================================
  Files          30       30              
  Lines        4976     4974       -2     
  Branches     1025     1024       -1     
==========================================
  Hits         4711     4711              
+ Misses        149      148       -1     
+ Partials      116      115       -1     
Impacted Files Coverage Δ
PyPDF2/_utils.py 100.00% <ø> (+1.11%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Comment thread PyPDF2/_utils.py
@@ -177,8 +177,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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the comment about "The stream's position should be unchanged" be removed since this is changing the final position of the stream before returning?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Thank you for the hint 🤗

Comment thread PyPDF2/_utils.py Outdated
Co-authored-by: Matthew Peveler <[email protected]>
@MartinThoma
MartinThoma merged commit 52463ea into main Aug 19, 2022
@MartinThoma
MartinThoma deleted the remove-dead-code-utils-read-backwards branch August 19, 2022 17:25
MartinThoma added a commit that referenced this pull request Aug 21, 2022
Robustness (ROB):
-  Decrypt returns empty bytestring (#1258)

Documentation (DOC):
-  Adding WevertonGomes as a Contributor

Developer Experience (DEV):
-  Modify CI to better verify built package contents (#1244)

Maintenance (MAINT):
-  Remove unused sign function in _extract_text (#1262)
-  Remove \'mine\' as PdfMerger always creates the stream (#1261)
-  Let PdfMerger._create_stream raise NotImplemented (#1251)
-  password param of _security._alg32(...) is only a string, not bytes (#1259)
-  Remove unreachable code in read_block_backwards (#1250)

Testing (TST):
-  Delete annotations (#1263)
-  Close PdfMerger in tests (#1260)
-  PdfReader.xmp_metadata workflow (#1257)
-  Various PdfWriter (Layout, Bookmark deprecation) (#1249)

Full Changelog: 2.10.2...2.10.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants