Repository navigation
ROB: Reject too few values when setting a page box - #4009
Merged
stefan6419846 merged 1 commit intoAug 26, 2026
Merged
Conversation
page.mediabox = ArrayObject([0, 0]) was accepted, but reading the box back raises ValueError because a rectangle cannot be built from two numbers, so the page could be written and not read. The getter warns and truncates when there are more than four values, for backwards compatibility with files pypdf itself once wrote, so the setter keeps accepting those and only refuses the case the getter cannot handle.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4009 +/- ##
=======================================
Coverage 97.98% 97.98%
=======================================
Files 57 57
Lines 11120 11122 +2
Branches 2084 2085 +1
=======================================
+ Hits 10896 10898 +2
Misses 125 125
Partials 99 99 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
stefan6419846
approved these changes
Aug 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
page.mediabox = ArrayObject([0, 0])is accepted, but reading the box back raises:So a page can be written with a box that cannot be read back.
The getter warns and truncates when there are more than four values, for backwards compatibility with files pypdf itself once wrote, so the setter keeps accepting those and only refuses the case the getter cannot handle. Writing through
page[NameObject("/MediaBox")]directly is untouched.Applies to all five boxes. Reverting the change fails the ten new tests