I see one fix is to also check if `elem.getparent() is not None`. Thoughts?

    elem.clear()
    while elem.getprevious() is not None and elem.getparent() is not None:
        del elem.getparent()[0]
_______________________________________________
lxml - The Python XML Toolkit mailing list -- lxml@python.org
To unsubscribe send an email to lxml-le...@python.org
https://mail.python.org/mailman3/lists/lxml.python.org/
Member address: arch...@mail-archive.com

Reply via email to