]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/pwdgrp.py
pwdgrp: pass strings to python for python 3
[bup.git] / lib / bup / pwdgrp.py
index cb8ccf3653a6363d437c646ad9a750035730dc80..485b4292db8e5fc17567f29057b630c74b3f31e1 100644 (file)
@@ -37,7 +37,9 @@ def getpwuid(uid):
     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))
 
 
 class Group:
@@ -63,7 +65,9 @@ def getgrgid(uid):
     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))
 
 
 _uid_to_pwd_cache = {}