Skip to content

fix: use pop() instead of del in process_none_page_numbersΒ #69

@luojiyin1987

Description

@luojiyin1987

Bug Description

The process_none_page_numbers function uses del item_copy['page'] which raises KeyError if the 'page' key doesn't exist.

Location

pageindex/page_index.py:677, 681

Problem

item_copy = copy.deepcopy(item)
del item_copy['page']  # KeyError if 'page' doesn't exist

The code assumes 'page' key always exists, but this may not be true for all TOC items.

Impact

  • Process crashes with KeyError: 'page'
  • Interrupts TOC processing pipeline

Suggested Fix

Use pop() with default value for safe removal:

item_copy.pop('page', None)  # Returns None if key doesn't exist, no error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions