Skip to content

ROB: Do not crash when the page resources are not a dictionary - #4054

Merged
stefan6419846 merged 2 commits into
py-pdf:mainfrom
RavSinghChandan:resources-not-a-dictionary
Sep 8, 2026
Merged

stefan6419846 merged 2 commits into
py-pdf:mainfrom
RavSinghChandan:resources-not-a-dictionary

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

extract_text casts the inherited /Resources into a dictionary and then tests
"/Font" in it, so a page whose /Resources is a number, a string or an array
crashes with "argument of type 'NumberObject' is not iterable" rather than
returning no text.

The lookup moved into a small helper that logs and returns an empty
dictionary, which gives the same result as a page with no resources at all.
Keeping it in a helper also avoids pushing _extract_text past the complexity
limit.

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

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

@codecov

codecov Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.10%. Comparing base (4b16bbb) to head (4b036e4).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4054      +/-   ##
==========================================
+ Coverage   98.09%   98.10%   +0.01%     
==========================================
  Files          58       59       +1     
  Lines       11394    11473      +79     
  Branches     2138     2147       +9     
==========================================
+ Hits        11177    11256      +79     
  Misses        122      122              
  Partials       95       95              

☔ 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 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The coverage is incomplete (is_null_or_none not covered).

@stefan6419846
stefan6419846 merged commit 948c9b5 into py-pdf:main Sep 8, 2026
59 of 62 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