andy-z / ged4py

GEDCOM tools for Python
MIT License
16 stars 7 forks source link

Possible crash in `sub_tag()` when file structure is inconsistent. #34

Closed andy-z closed 3 years ago

andy-z commented 3 years ago

I got a report that ged4py crashes on some input in unexpected place, here is traceback:

AttributeError                            Traceback (most recent call last)

<ipython-input-11-060546d0b728> in <module>()
      3         print(f"{i}: {indi.name.format()}")
      4 
----> 5         father = indi.father
      6         if father:
      7             print(f"    father: {father.name.format()}")

/usr/local/lib/python3.7/dist-packages/ged4py/model.py in sub_tag(self, path, follow)
    168         rec = self
    169         for tag in tags:
--> 170             recs = [x for x in (rec.sub_records or []) if x.tag == tag]
    171             if not recs:
    172                 return None

This could happen if pointer record (FAMC in this example) points to non-existing record.

Need to build a test case and add a workaround.