diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2002-09-17 09:34:06 +0000 |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2002-09-17 09:34:06 +0000 |
commit | 3053384814d91403fe86d4cbfc1a36a7d6e3ffe3 (patch) | |
tree | 95bbce01214419db5ac9be89a3f0724ebe8858f9 /Modules/pwdmodule.c | |
parent | 3cc1e16b332512293e5cec3bc950685ae0547588 (diff) | |
download | cpython-3053384814d91403fe86d4cbfc1a36a7d6e3ffe3.tar.gz |
Deal with NULL fields in mkpwent.
Diffstat (limited to 'Modules/pwdmodule.c')
-rw-r--r-- | Modules/pwdmodule.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Modules/pwdmodule.c b/Modules/pwdmodule.c index cb139bb036..9134edc1b1 100644 --- a/Modules/pwdmodule.c +++ b/Modules/pwdmodule.c @@ -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); |