Skip to content

ROB: Do not crash when the annotations are not an array - #4046

Merged
stefan6419846 merged 1 commit into
py-pdf:mainfrom
RavSinghChandan:annotations-not-an-array
Sep 4, 2026
Merged

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

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

page.annotations casts the /Annots entry to an array and hands it straight back, so
a page whose /Annots is a number, a string or a dictionary crashes with
"'NumberObject' object is not iterable" as soon as anything iterates it.

The property is already typed Optional[ArrayObject] and returns None when /Annots is
absent, so an entry that cannot be one is logged and returns None as well. The writer
paths that use it already check for None.

I could not run the tests that download the corpus locally; the offline suite passes,
1262 tests.

Used Claude (Opus) to help locate and patch this; I reviewed and tested the change.

@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.05%. Comparing base (a667e9d) to head (6dcbbb5).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4046   +/-   ##
=======================================
  Coverage   98.05%   98.05%           
=======================================
  Files          57       57           
  Lines       11273    11277    +4     
  Branches     2131     2132    +1     
=======================================
+ Hits        11054    11058    +4     
  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 d3f790c into py-pdf:main Sep 4, 2026
33 of 34 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