Skip to content

ROB: Do not crash when the destination tree is not a dictionary - #4020

Merged
stefan6419846 merged 1 commit into
py-pdf:mainfrom
RavSinghChandan:named-destinations-not-a-dictionary
Aug 28, 2026
Merged

stefan6419846 merged 1 commit into
py-pdf:mainfrom
RavSinghChandan:named-destinations-not-a-dictionary

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

_get_named_destinations casts /Dests and /Names to a DictionaryObject and then tests membership on the result, so a file where either holds a number, a string or an array brings down the read:

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

The references are resolved first, since both are usually indirect, and a tree that cannot be walked is reported the way the cycle in the same function already is.

Reverting the change fails the four new tests

@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.01%. Comparing base (58fd80a) to head (5fd3a10).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4020   +/-   ##
=======================================
  Coverage   98.01%   98.01%           
=======================================
  Files          57       57           
  Lines       11157    11163    +6     
  Branches     2096     2098    +2     
=======================================
+ Hits        10935    10941    +6     
  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.

Comment thread tests/test_doc_common.py Resolved
@RavSinghChandan
RavSinghChandan force-pushed the named-destinations-not-a-dictionary branch from 031caaa to faaf108 Compare August 27, 2026 02:32
@RavSinghChandan

Copy link
Copy Markdown
Contributor Author

Added the IDs.

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

I am sorry, GitHub seems to somehow have messed up when I tried to merge the latest changes from main into your branch.

Could you please check if you are able to resolve this in a clean fashion? Thanks.

@RavSinghChandan
RavSinghChandan force-pushed the named-destinations-not-a-dictionary branch 2 times, most recently from dd04d68 to a1b8eff Compare August 27, 2026 14:41
_get_named_destinations casts /Dests and /Names to a DictionaryObject and then
tests membership on the result, so a file where either holds a number, a string
or an array raised 'TypeError: argument of type NumberObject is not iterable'
from reader.named_destinations.

The references are resolved first, since both are usually indirect, and a tree
that cannot be walked is reported the way the cycle in the same function
already is.
@RavSinghChandan
RavSinghChandan force-pushed the named-destinations-not-a-dictionary branch from a1b8eff to 5fd3a10 Compare August 28, 2026 03:41
@stefan6419846
stefan6419846 merged commit 5c2ec34 into py-pdf:main Aug 28, 2026
32 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