Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Poikilos opened this issue Apr 6, 2024 · 0 comments
Open

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

Poikilos opened this issue Apr 6, 2024 · 0 comments

Comments

@Poikilos
Copy link
Collaborator

Poikilos commented Apr 6, 2024

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*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant