Python 3's getpwnam and getgrnam functions only accept unicode
strings, so decode the bytes we have as iso-8859-1, which is what they
should be, given bup-python's LC_CTYPE override.
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
return _passwd_from_py(pwd.getpwuid(uid))
def getpwnam(name):
return _passwd_from_py(pwd.getpwuid(uid))
def getpwnam(name):
- return _passwd_from_py(pwd.getpwnam(name))
+ assert isinstance(name, bytes)
+ return _passwd_from_py(pwd.getpwnam(name.decode('iso-8859-1') if py_maj > 2
+ else name))
return _group_from_py(grp.getgrgid(uid))
def getgrnam(name):
return _group_from_py(grp.getgrgid(uid))
def getgrnam(name):
- return _group_from_py(grp.getgrnam(name))
+ assert isinstance(name, bytes)
+ return _group_from_py(grp.getgrnam(name.decode('iso-8859-1') if py_maj > 2
+ else name))