make the user2uid/group2gid win32 hack behave more like the real code (e.g. posix)

The code relies on them returning the default value (usually
None), if we call user2uid(None) or group2gid(None) (same for
empty string).
This commit is contained in:
Thomas Waldmann 2023-01-19 18:35:38 +01:00
parent 7bd8e924eb
commit 7ab39f9d42
No known key found for this signature in database
GPG Key ID: 243ACFA951F78E01
1 changed files with 6 additions and 0 deletions

View File

@ -21,6 +21,9 @@ def uid2user(uid, default=None):
@lru_cache(maxsize=None)
def user2uid(user, default=None):
if not user:
# user is either None or the empty string
return default
return 0
@ -31,6 +34,9 @@ def gid2group(gid, default=None):
@lru_cache(maxsize=None)
def group2gid(group, default=None):
if not group:
# group is either None or the empty string
return default
return 0