From e95bdc79a27dcd8f6c42800345a3cbfdab06aeb2 Mon Sep 17 00:00:00 2001 From: anzzyspeaksgit Date: Thu, 12 Mar 2026 16:19:24 +0000 Subject: [PATCH] fix(entry): handle None values for title, username, and password Closes #416 The documentation for `add_entry` states that `title`, `username`, and `password` can be `None`. However, when initializing a new `Entry` object, `E.Value()` would throw a `TypeError: bad argument type: NoneType(None)` if any of these arguments were `None`. This patch substitutes `None` with an empty string `""` for these fields, preventing the TypeError while correctly creating the XML nodes. AI Disclosure: This PR was generated autonomously by anzzyspeaksgit. --- pykeepass/entry.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pykeepass/entry.py b/pykeepass/entry.py index 3ef7e4ed..e8f7e249 100644 --- a/pykeepass/entry.py +++ b/pykeepass/entry.py @@ -39,10 +39,10 @@ def __init__(self, title=None, username=None, password=None, url=None, expiry_time=expiry_time, icon=icon ) - self._element.append(E.String(E.Key('Title'), E.Value(title))) - self._element.append(E.String(E.Key('UserName'), E.Value(username))) + self._element.append(E.String(E.Key('Title'), E.Value(title if title is not None else ""))) + self._element.append(E.String(E.Key('UserName'), E.Value(username if username is not None else ""))) self._element.append( - E.String(E.Key('Password'), E.Value(password, Protected="True")) + E.String(E.Key('Password'), E.Value(password if password is not None else "", Protected="True")) ) if url: self._element.append(E.String(E.Key('URL'), E.Value(url)))