Skip to content

ROB: Reject a page box that is not an array - #4041

Merged
stefan6419846 merged 1 commit into
py-pdf:mainfrom
RavSinghChandan:page-box-not-an-array
Sep 2, 2026
Merged

stefan6419846 merged 1 commit into
py-pdf:mainfrom
RavSinghChandan:page-box-not-an-array

Conversation

@RavSinghChandan

@RavSinghChandan RavSinghChandan commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

_get_rectangle checks the length only when the value is already an ArrayObject.
Anything else falls through to RectangleObject(retval) behind a type: ignore, where
it fails with "object of type 'NumberObject' has no len()" - which says nothing about
which box was wrong.

It now raises a ValueError naming the box, in the same wording as the existing
too-few-values error a few lines below, and the type: ignore is no longer needed.

This is not a behavioural change in the sense of newly rejecting a valid file: the
old code already failed on the same input, just with a less useful error.

I could not run the tests that download the corpus locally; the offline suite passes,
1237 tests.
Used Claude (Opus) to help locate and patch this; I reviewed and tested the change.

@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.04%. Comparing base (939ae0c) to head (1d080c6).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4041   +/-   ##
=======================================
  Coverage   98.04%   98.04%           
=======================================
  Files          57       57           
  Lines       11225    11227    +2     
  Branches     2114     2115    +1     
=======================================
+ Hits        11006    11008    +2     
  Misses        122      122           
  Partials       97       97           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@stefan6419846
stefan6419846 merged commit 3818d66 into py-pdf:main Sep 2, 2026
21 checks passed
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