[issue35070] test_posix fails on macOS 10.14 Mojave

Barry A. Warsaw report at bugs.python.org
Fri Oct 26 16:35:05 EDT 2018


Barry A. Warsaw <barry at python.org> added the comment:

Yes, I've rebooted :)   I've modified your C program a little and here's the code and output.

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

int main()
{
    gid_t grouplist[32];
    int n;
    int gidsetsize;

    for (gidsetsize = 0; gidsetsize < 22; ++gidsetsize) {
        n = getgroups(gidsetsize, grouplist);
        printf("calling grouplist with gidsetsize = %i, returns %i: ", gidsetsize, n);
        for (int j = 0; j < n; j++) {
            printf("%i ", grouplist[j]);
        }
        printf("\n");
    }
    exit(0);
}

calling grouplist with gidsetsize = 0, returns 15: -483891656 32766 -483891672 32766 -483891728 32766 427353334 1 -483891696 32766 0 0 0 0 -483891672 
calling grouplist with gidsetsize = 1, returns -1: 
calling grouplist with gidsetsize = 2, returns -1: 
calling grouplist with gidsetsize = 3, returns -1: 
calling grouplist with gidsetsize = 4, returns -1: 
calling grouplist with gidsetsize = 5, returns -1: 
calling grouplist with gidsetsize = 6, returns -1: 
calling grouplist with gidsetsize = 7, returns -1: 
calling grouplist with gidsetsize = 8, returns -1: 
calling grouplist with gidsetsize = 9, returns -1: 
calling grouplist with gidsetsize = 10, returns -1: 
calling grouplist with gidsetsize = 11, returns -1: 
calling grouplist with gidsetsize = 12, returns -1: 
calling grouplist with gidsetsize = 13, returns -1: 
calling grouplist with gidsetsize = 14, returns -1: 
calling grouplist with gidsetsize = 15, returns 15: 101 503 701 501 12 62 80 502 33 98 100 204 250 395 398 
calling grouplist with gidsetsize = 16, returns 15: 101 503 701 501 12 62 80 502 33 98 100 204 250 395 398 
calling grouplist with gidsetsize = 17, returns 15: 101 503 701 501 12 62 80 502 33 98 100 204 250 395 398 
calling grouplist with gidsetsize = 18, returns 15: 101 503 701 501 12 62 80 502 33 98 100 204 250 395 398 
calling grouplist with gidsetsize = 19, returns 15: 101 503 701 501 12 62 80 502 33 98 100 204 250 395 398 
calling grouplist with gidsetsize = 20, returns 15: 101 503 701 501 12 62 80 502 33 98 100 204 250 395 398 
calling grouplist with gidsetsize = 21, returns 15: 101 503 701 501 12 62 80 502 33 98 100 204 250 395 398 

% id -G
101 503 701 501 12 62 80 502 33 98 100 204 250 395 398

I've also made a small change to test_posix.py:

diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 86c04b9f32..5074b45fc0 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -1047,8 +1047,9 @@ class PosixTester(unittest.TestCase):
         # groups, ignoring order, duplicates, and the effective gid.
         # #10822/#26944 - It is implementation defined whether
         # posix.getgroups() includes the effective gid.
-        symdiff = idg_groups.symmetric_difference(posix.getgroups())
-        self.assertTrue(not symdiff or symdiff == {posix.getegid()})
+        groups = posix.getgroups()
+        symdiff = idg_groups.symmetric_difference(groups)
+        self.assertTrue(not symdiff or symdiff == {posix.getegid()}, (idg_groups, groups, symdiff))
 
     # tests for the posix *at functions follow
 
But when I run ./python.exe -m test test.test_posix here's what I get:

Run tests sequentially
0:00:00 load avg: 1.62 [1/1] test.test_posix
test test.test_posix failed -- Traceback (most recent call last):
  File "/Users/bwarsaw/projects/python/cpython/Lib/test/test_posix.py", line 1052, in test_getgroups
    self.assertTrue(not symdiff or symdiff == {posix.getegid()}, (idg_groups, groups, symdiff))
AssertionError: False is not true : ({33, 98, 100, 101, 395, 12, 204, 398, 80, 501, 502, 503, 250, 701, 62}, [101], {33, 98, 100, 395, 12, 204, 398, 80, 501, 502, 503, 250, 701, 62})

So it seems like getgroups(2) is doing the right thing, but not Python.  Weird.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35070>
_______________________________________


More information about the Python-bugs-list mailing list