diff -r 4f7845be9e23 Modules/spwdmodule.c --- a/Modules/spwdmodule.c Mon Aug 19 23:31:18 2013 +0200 +++ b/Modules/spwdmodule.c Tue Aug 20 12:11:03 2013 +0800 @@ -122,7 +122,12 @@ if (PyBytes_AsStringAndSize(bytes, &name, NULL) == -1) goto out; if ((p = getspnam(name)) == NULL) { - PyErr_SetString(PyExc_KeyError, "getspnam(): name not found"); + if (errno==EACCES) { + PyErr_SetString(PyExc_OSError, "getspnam(): the caller does not " + "have permission to access the shadow password file"); + } else { + PyErr_SetString(PyExc_KeyError, "getspnam(): name not found"); + } goto out; } retval = mkspent(p);