Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 43d9fa2

Browse files
Issue #17248: Fix os.*chown() testing when user has group root.
2 parents f060206 + b3d62ce commit 43d9fa2

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Lib/test/test_posix.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,11 @@ def check_stat(uid, gid):
451451
# non-root cannot chown to root, raises OSError
452452
self.assertRaises(OSError, chown_func, first_param, 0, 0)
453453
check_stat(uid, gid)
454-
self.assertRaises(OSError, chown_func, first_param, -1, 0)
455-
check_stat(uid, gid)
456454
self.assertRaises(OSError, chown_func, first_param, 0, -1)
457455
check_stat(uid, gid)
456+
if gid != 0:
457+
self.assertRaises(OSError, chown_func, first_param, -1, 0)
458+
check_stat(uid, gid)
458459
# test illegal types
459460
for t in str, float:
460461
self.assertRaises(TypeError, chown_func, first_param, t(uid), gid)

0 commit comments

Comments
 (0)