[RFC PATCH 07/13] ez: use portable uid/gid accessors in write_to_tar
Adrian Neftali Sanchez <[email protected]>
| Newsgroups | org.kernel.linux.tools |
|---|---|
| Message-ID | <[email protected]> |
os.getuid and os.getgid are POSIX-only; calling them directly raises AttributeError on Windows. Use getattr with a lambda returning 0 so tar entries are created with a harmless numeric uid/gid on platforms that do not have POSIX user identifiers. Signed-off-by: Adrian Neftali Sanchez <[email protected]> --- src/b4/ez.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/b4/ez.py b/src/b4/ez.py index 3e81138..51fbdc9 100644 --- a/src/b4/ez.py +++ b/src/b4/ez.py @@ -2800,8 +2800,8 @@ def write_to_tar( ) -> None: tifo = tarfile.TarInfo(name) tuser = os.environ.get('USERNAME', 'user') - tuid = os.getuid() - tgid = os.getgid() + tuid = getattr(os, 'getuid', lambda: 0)() + tgid = getattr(os, 'getgid', lambda: 0)() tifo.uid = tuid tifo.gid = tgid tifo.uname = tuser -- 2.45.0.windows.1