Raise KeyError instead of OverflowError when getpwuid's argument is out of

uid_t range.
This commit is contained in:
Serhiy Storchaka 2013-02-11 20:32:47 +02:00
parent 66383b2e0a
commit 55e2238272
2 changed files with 14 additions and 1 deletions

View file

@ -106,8 +106,12 @@ pwd_getpwuid(PyObject *self, PyObject *args)
{
uid_t uid;
struct passwd *p;
if (!PyArg_ParseTuple(args, "O&:getpwuid", _Py_Uid_Converter, &uid))
if (!PyArg_ParseTuple(args, "O&:getpwuid", _Py_Uid_Converter, &uid)) {
if (PyErr_ExceptionMatches(PyExc_OverflowError))
PyErr_Format(PyExc_KeyError,
"getpwuid(): uid not found");
return NULL;
}
if ((p = getpwuid(uid)) == NULL) {
PyObject *uid_obj = _PyLong_FromUid(uid);
if (uid_obj == NULL)