Skip to content

Unclear error in lxml (may be able to be improved in pykeepass) #37

@Poikilos

Description

@Poikilos

Occurs when search is blank.

Traceback (most recent call last):
  File "/home/owner/git/linux-preinstall/utilities/diffkeepass.py", line 378, in <module>
    sys.exit(main())
  File "/home/owner/git/linux-preinstall/utilities/diffkeepass.py", line 334, in main
    compare_keepass(
  File "/home/owner/git/linux-preinstall/utilities/diffkeepass.py", line 148, in compare_keepass
    entry1 = kp1.find_entries(title=entry2.title, first=True)
  File "/home/owner/.local/lib/python3.10/site-packages/pykeepass/pykeepass.py", line 516, in find_entries
    res = self._find(prefix, entry_xp, path=path, tree=group, **kwargs)
  File "/home/owner/.local/lib/python3.10/site-packages/pykeepass/pykeepass.py", line 399, in _find
    res = self._xpath(
  File "/home/owner/.local/lib/python3.10/site-packages/pykeepass/pykeepass.py", line 321, in _xpath
    elements = tree.xpath(
  File "src/lxml/etree.pyx", line 2311, in lxml.etree._ElementTree.xpath
  File "src/lxml/xpath.pxi", line 357, in lxml.etree.XPathDocumentEvaluator.__call__
  File "src/lxml/xpath.pxi", line 225, in lxml.etree._XPathEvaluatorBase._handle_result
lxml.etree.XPathEvalError: Invalid predicate

workaround:

-        if not entry1:
+        if not entry1 and entry2.title:
            entry1 = kp1.find_entries(title=entry2.title, first=True)
  • also avoid other uses of None in find_entries*

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions