Merge pull request #167 from VectifyAI/fix/list-index-shadowing

Fix list_index variable shadowing in fix_incorrect_toc
This commit is contained in:
Bukely_ 2026-03-16 14:20:32 +08:00 committed by GitHub
commit 4b4b20f9c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -807,9 +807,9 @@ async def fix_incorrect_toc(toc_with_page_number, page_list, incorrect_results,
page_contents=[]
for page_index in range(prev_correct, next_correct+1):
# Add bounds checking to prevent IndexError
list_index = page_index - start_index
if list_index >= 0 and list_index < len(page_list):
page_text = f"<physical_index_{page_index}>\n{page_list[list_index][0]}\n<physical_index_{page_index}>\n\n"
page_list_idx = page_index - start_index
if page_list_idx >= 0 and page_list_idx < len(page_list):
page_text = f"<physical_index_{page_index}>\n{page_list[page_list_idx][0]}\n<physical_index_{page_index}>\n\n"
page_contents.append(page_text)
else:
continue