7063: endless loop in probably_alive_range

Add a hack protection for descendants like we already have
for ancestors, and add a debug printout.

svn: r23117
This commit is contained in:
Vassilii Khachaturov 2013-09-13 17:54:23 +00:00
parent c3e131fe3e
commit 3ab55427a1

View File

@ -830,13 +830,15 @@ class ProbablyAlive(object):
date1, date2, explain, other = descendants_too_old(person, self.AVG_GENERATION_GAP) date1, date2, explain, other = descendants_too_old(person, self.AVG_GENERATION_GAP)
except RuntimeError: except RuntimeError:
raise Errors.DatabaseError( raise Errors.DatabaseError(
_("Database error: %s is defined as his or her own ancestor") % _("Database error: loop in %s's descendants") %
name_displayer.display(person)) name_displayer.display(person))
if date1 and date2: if date1 and date2:
return (date1, date2, explain, other) return (date1, date2, explain, other)
def ancestors_too_old(person, year): def ancestors_too_old(person, year):
LOG.debug("ancestors_too_old('{}', {})".format(
name_displayer.display(person), year) )
family_handle = person.get_main_parents_family_handle() family_handle = person.get_main_parents_family_handle()
if family_handle: if family_handle:
family = self.db.get_family_from_handle(family_handle) family = self.db.get_family_from_handle(family_handle)
@ -938,9 +940,14 @@ class ProbablyAlive(object):
return (None, None, "", None) return (None, None, "", None)
# If there are ancestors that would be too old in the current year try:
# then assume our person must be dead too. # If there are ancestors that would be too old in the current year
date1, date2, explain, other = ancestors_too_old (person, - self.AVG_GENERATION_GAP) # then assume our person must be dead too.
date1, date2, explain, other = ancestors_too_old (person, - self.AVG_GENERATION_GAP)
except RuntimeError:
raise Errors.DatabaseError(
_("Database error: loop in %s's ancestors") %
name_displayer.display(person))
if date1 and date2: if date1 and date2:
return (date1, date2, explain, other) return (date1, date2, explain, other)