summaryrefslogtreecommitdiffstats
path: root/Modules/pwdmodule.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-02-11 18:32:47 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-02-11 18:32:47 (GMT)
commit55e2238272daf0a6b585cf6314abb9fdf768bbde (patch)
tree8d543e3fe04ce4b25ed75839c19449ed5db3ae86 /Modules/pwdmodule.c
parent66383b2e0a47cebf31586a1038e85d37c9aefadc (diff)
downloadcpython-55e2238272daf0a6b585cf6314abb9fdf768bbde.zip
cpython-55e2238272daf0a6b585cf6314abb9fdf768bbde.tar.gz
cpython-55e2238272daf0a6b585cf6314abb9fdf768bbde.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.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Modules/pwdmodule.c b/Modules/pwdmodule.c
index 632ffe3..285fd9c 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)