Skip to content

Commit ba95930

Browse files
committed
Merge upstream PR libkeepass#418: Allow password to be skipped or set to None in add_entry
Fixes TypeError when passing password=None to add_entry(), which the documentation already stated was allowed. See: libkeepass#418
2 parents 1633aa7 + 1695e04 commit ba95930

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

pykeepass/entry.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ def __init__(self, title=None, username=None, password=None, url=None,
4141
)
4242
self._element.append(E.String(E.Key('Title'), E.Value(title)))
4343
self._element.append(E.String(E.Key('UserName'), E.Value(username)))
44-
self._element.append(
45-
E.String(E.Key('Password'), E.Value(password, Protected="True"))
46-
)
44+
# Allowing password to be None
45+
if password is not None:
46+
self._element.append(
47+
E.String(E.Key('Password'), E.Value(password, Protected="True"))
48+
)
4749
if url:
4850
self._element.append(E.String(E.Key('URL'), E.Value(url)))
4951
if notes:

pykeepass/pykeepass.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ def find_entries(self, recursive=True, path=None, group=None, **kwargs):
648648

649649

650650
def add_entry(self, destination_group, title, username,
651-
password, url=None, notes=None, expiry_time=None,
651+
password=None, url=None, notes=None, expiry_time=None,
652652
tags=None, otp=None, icon=None, force_creation=False):
653653

654654
"""Create a new entry

0 commit comments

Comments
 (0)