diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-11 18:33:24 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-11 18:33:24 (GMT) |
commit | fd6e6cfa29b2289e711dc7f57f36897c78899ee7 (patch) | |
tree | 8c4e153142c5cd0d123b2f53c0aee00223512ec2 /Modules/pwdmodule.c | |
parent | 64634eb32112c84b858ba58729e7c7246affad34 (diff) | |
parent | 55e2238272daf0a6b585cf6314abb9fdf768bbde (diff) | |
download | cpython-fd6e6cfa29b2289e711dc7f57f36897c78899ee7.zip cpython-fd6e6cfa29b2289e711dc7f57f36897c78899ee7.tar.gz cpython-fd6e6cfa29b2289e711dc7f57f36897c78899ee7.tar.bz2 |
Raise KeyError instead of OverflowError when getpwuid's argument is out of
uid_t range.
Diffstat (limited to 'Modules/pwdmodule.c')
-rw-r--r-- | Modules/pwdmodule.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Modules/pwdmodule.c b/Modules/pwdmodule.c index 4807aa3..d4ef733 100644 --- a/Modules/pwdmodule.c +++ b/Modules/pwdmodule.c @@ -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) |