Repository navigation
Conversation
calculate_page_offset() returns None when no reliable page->physical offset can be computed (e.g. no title matches between the printed TOC and the extracted physical indices). Passing that None into add_page_offset_to_toc_json crashed with TypeError: unsupported operand type(s) for +: 'int' and 'NoneType' (issue VectifyAI#153). Leave items untouched when offset is None; process_none_page_numbers() downstream already resolves physical indices for items that lack one. Adds tests/test_issue_153.py regression tests. Signed-off-by: Yeshvanth Raju Kurapati <76988460+cxx5208@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #153.
What was wrong
When the printed-page TOC and the extracted physical indices share no matching titles,
calculate_page_offset()returnsNone(no reliable page→physical offset exists).add_page_offset_to_toc_json()then computeddata[i]['page'] + offset— i.e.int + None— and crashed with:Fix
In
add_page_offset_to_toc_json()(pageindex/page_index_classic.py), return the items untouched whenoffsetisNoneinstead of crashing. This is safe becauseprocess_none_page_numbers(), which runs right after inprocess_toc_with_page_numbers(), is already designed to resolve physical indices for items that lack one.Tests
TypeErrorfrom the issue before the fix with a minimal script (empty pairs →offset=None→ crash).physical_indexcorrectly.tests/test_issue_153.pywith 5 regression tests (follows the existingtest_issue_163.pyconvention).test_page_index_md.pyare pre-existing on the clean tree (missing optional deps), unrelated to this change.