[Python-checkins] CVS: python/dist/src/Modules posixmodule.c,2.176,2.177
Fred L. Drake
python-dev@python.org
Wed, 6 Dec 2000 13:24:31 -0800
Update of /cvsroot/python/python/dist/src/Modules
In directory slayer.i.sourceforge.net:/tmp/cvs-serv5197
Modified Files:
posixmodule.c
Log Message:
posix_getlogin(): Handle the possibility that getlogin() can return
NULL without setting errno; observed on Linux
Mandrake 7.2 by an anonymous user.
This closes bug #124758.
Index: posixmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v
retrieving revision 2.176
retrieving revision 2.177
diff -C2 -r2.176 -r2.177
*** posixmodule.c 2000/10/24 19:57:44 2.176
--- posixmodule.c 2000/12/06 21:24:28 2.177
***************
*** 1905,1914 ****
if (PyArg_ParseTuple(args, ":getlogin")) {
! char *name = getlogin();
! if (name == NULL)
! posix_error();
else
result = PyString_FromString(name);
}
return result;
--- 1905,1923 ----
if (PyArg_ParseTuple(args, ":getlogin")) {
! char *name;
! int old_errno = errno;
! errno = 0;
! name = getlogin();
! if (name == NULL) {
! if (errno)
! posix_error();
! else
! PyErr_SetString(PyExc_OSError,
! "unexpected NULL from getlogin()");
! }
else
result = PyString_FromString(name);
+ errno = old_errno;
}
return result;