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