mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
Raise KeyError instead of OverflowError when getpwuid's argument is out of
uid_t range.
This commit is contained in:
parent
66383b2e0a
commit
55e2238272
2 changed files with 14 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue