Skip to content

ROB: Do not crash when the page labels are not a dictionary - #4022

Merged
stefan6419846 merged 2 commits into
py-pdf:mainfrom
RavSinghChandan:page-labels-not-a-dictionary
Aug 27, 2026
Merged

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

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

index2label casts /PageLabels to a DictionaryObject and tests membership on the result:

>>> reader.page_labels
TypeError: argument of type 'NumberObject' is not iterable

The function already falls back to the page position when /PageLabels is absent, so an entry it cannot read is reported and takes the same path.

Reverting the change fails the three new tests

Comment thread tests/test_page_labels.py Resolved
@codecov

codecov Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.00%. Comparing base (d85ef0f) to head (44f4674).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4022   +/-   ##
=======================================
  Coverage   98.00%   98.00%           
=======================================
  Files          57       57           
  Lines       11136    11139    +3     
  Branches     2090     2091    +1     
=======================================
+ Hits        10914    10917    +3     
  Misses        124      124           
  Partials       98       98           

☔ 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.

index2label casts /PageLabels to a DictionaryObject and tests membership on
the result, so a file where that entry holds a number, a string or an array
raised 'TypeError: argument of type NumberObject is not iterable' from
reader.page_labels.

The function already falls back to the page position when /PageLabels is
absent, so an entry it cannot read is reported and takes the same path.
@RavSinghChandan
RavSinghChandan force-pushed the page-labels-not-a-dictionary branch from 7d53683 to 44f4674 Compare August 27, 2026 02:35
@RavSinghChandan

Copy link
Copy Markdown
Contributor Author

Added the IDs.

@stefan6419846
stefan6419846 merged commit 486a203 into py-pdf:main Aug 27, 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