Skip to content

Commit 3c79b8a

Browse files
hgohelGaryGriffin
authored andcommitted
Fix unhandled exception when omit duplicate option is used with index of names
The issue was that report_app_ref, index_of_dates, and index_of_places were only initialized when the dubperson (i.e. omit duplicates) option was enabled, but they were accessed unconditionally in methods like write_index_of_names, append_event, and write_report_ref. This lead to an `AttributeError` when later code tried to access them. AI was asked to analyze the call stack and fix the issue. Validation and verification of fix was performed by me. Generated-by: Cline v3.27.0; x-ai/grok-code-fast-1 Fixes #12859, #12857
1 parent 481d77f commit 3c79b8a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

DescendantBooks/DetailedDescendantBookReport.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,11 @@ def write_report(self):
353353
self.ca = CollectAscendants(self.database, self.user, self.title)
354354
self.ascendants = self.ca.collect_data(self.filter, self.center_person)
355355

356+
# Initialize attributes used for indexing and references
357+
self.report_app_ref = {}
358+
self.index_of_dates = {}
359+
self.index_of_places = {}
360+
356361
if self.dubperson:
357362
if len(self.ascendants) > 1:
358363
self.user.begin_progress(self.title,
@@ -362,10 +367,7 @@ def write_report(self):
362367
# Need to do two runs of generations,
363368
# 1st run gets references for all people/mates in report
364369
# 2nd run actually generates the report and includes the references
365-
self.report_app_ref = {}
366370
self.report_count = 0
367-
self.index_of_dates = {}
368-
self.index_of_places = {}
369371
self.phandle = 0 # person handle used by append_event to retrieve name and references to the current person
370372
for asc_handle in self.ascendants:
371373
if len(self.ascendants) > 1:

0 commit comments

Comments
 (0)