Commit 29275c93 authored by Martin v. Löwis's avatar Martin v. Löwis

Deal with NULL fields in mkpwent.

parent ceb7c18c
......@@ -44,6 +44,17 @@ exception is raised if the entry asked for cannot be found.");
static PyTypeObject StructPwdType;
static void
sets(PyObject *v, int i, char* val)
{
if (val)
PyStructSequence_SET_ITEM(v, i, PyString_FromString(val));
else {
PyStructSequence_SET_ITEM(v, i, Py_None);
Py_INCREF(Py_None);
}
}
static PyObject *
mkpwent(struct passwd *p)
{
......@@ -53,7 +64,7 @@ mkpwent(struct passwd *p)
return NULL;
#define SETI(i,val) PyStructSequence_SET_ITEM(v, i, PyInt_FromLong((long) val))
#define SETS(i,val) PyStructSequence_SET_ITEM(v, i, PyString_FromString(val))
#define SETS(i,val) sets(v, i, val)
SETS(setIndex++, p->pw_name);
SETS(setIndex++, p->pw_passwd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment