summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorR. David Murray <rdmurray@bitdance.com>2010-12-14 16:20:53 (GMT)
committerR. David Murray <rdmurray@bitdance.com>2010-12-14 16:20:53 (GMT)
commitec07331eea496469165dc3be45fadbeab641e083 (patch)
tree3961e67fea53d641e0aa587db146fb4ab40b623e
parenta80f4fb0481237e4ca4a9d9a57c52e0181b638f9 (diff)
downloadcpython-ec07331eea496469165dc3be45fadbeab641e083.zip
cpython-ec07331eea496469165dc3be45fadbeab641e083.tar.gz
cpython-ec07331eea496469165dc3be45fadbeab641e083.tar.bz2
#775964: skip YP/NIS entries instead of failing the test
Also includes doc updates mentioning that these entries may not be retrievable via getgrnam and getgrgid. Patch by Bobby Impollonia.
-rw-r--r--Doc/library/grp.rst4
-rw-r--r--Lib/test/test_grp.py8
-rw-r--r--Misc/ACKS1
-rw-r--r--Misc/NEWS7
-rw-r--r--Modules/grpmodule.c4
5 files changed, 20 insertions, 4 deletions
diff --git a/Doc/library/grp.rst b/Doc/library/grp.rst
index 57f160a..8882140 100644
--- a/Doc/library/grp.rst
+++ b/Doc/library/grp.rst
@@ -30,7 +30,9 @@ correspond to the members of the ``group`` structure (Attribute field below, see
The gid is an integer, name and password are strings, and the member list is a
list of strings. (Note that most users are not explicitly listed as members of
the group they are in according to the password database. Check both databases
-to get complete membership information.)
+to get complete membership information. Also note that a ``gr_name`` that
+starts with a ``+`` or ``-`` is likely to be a YP/NIS reference and may not be
+accessible via :func:`getgrnam` or :func:`getgrgid`.)
It defines the following items:
diff --git a/Lib/test/test_grp.py b/Lib/test/test_grp.py
index dafd905..04a8af6 100644
--- a/Lib/test/test_grp.py
+++ b/Lib/test/test_grp.py
@@ -33,12 +33,16 @@ class GroupDatabaseTestCase(unittest.TestCase):
e2 = grp.getgrgid(e.gr_gid)
self.check_value(e2)
self.assertEqual(e2.gr_gid, e.gr_gid)
- e2 = grp.getgrnam(e.gr_name)
+ name = e.gr_name
+ if name.startswith('+') or name.startswith('-'):
+ # NIS-related entry
+ continue
+ e2 = grp.getgrnam(name)
self.check_value(e2)
# There are instances where getgrall() returns group names in
# lowercase while getgrgid() returns proper casing.
# Discovered on Ubuntu 5.04 (custom).
- self.assertEqual(e2.gr_name.lower(), e.gr_name.lower())
+ self.assertEqual(e2.gr_name.lower(), name.lower())
def test_errors(self):
self.assertRaises(TypeError, grp.getgrgid)
diff --git a/Misc/ACKS b/Misc/ACKS
index bc5821d..5dfb8da 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -398,6 +398,7 @@ Gerhard Häring
Fredrik Håård
Mihai Ibanescu
Lars Immisch
+Bobby Impollonia
Meador Inge
Tony Ingraldi
John Interrante
diff --git a/Misc/NEWS b/Misc/NEWS
index 981b53f..2b6c78c 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -38,6 +38,13 @@ Library
or otherwise not wait for exiting child processes.
+Tests
+-----
+
+- Issue #775964: test_grp now skips YP/NIS entries instead of failing when
+ encountering them.
+
+
What's New in Python 3.2 Beta 1?
================================
diff --git a/Modules/grpmodule.c b/Modules/grpmodule.c
index 97a3783..7dfda28 100644
--- a/Modules/grpmodule.c
+++ b/Modules/grpmodule.c
@@ -159,7 +159,9 @@ Return the group database entry for the given group name. If\n\
name is not valid, raise KeyError."},
{"getgrall", grp_getgrall, METH_NOARGS,
"getgrall() -> list of tuples\n\
-Return a list of all available group entries, in arbitrary order."},
+Return a list of all available group entries, in arbitrary order.\n\
+An entry whose name starts with '+' or '-' represents an instruction\n\
+to use YP/NIS and may not be accessible via getgrnam or getgrgid."},
{NULL, NULL} /* sentinel */
};