diff options
author | Skip Montanaro <skip@pobox.com> | 2006-04-20 01:29:48 (GMT) |
---|---|---|
committer | Skip Montanaro <skip@pobox.com> | 2006-04-20 01:29:48 (GMT) |
commit | 94785ef14294e9d924c9ceee3d6f9082d4555f28 (patch) | |
tree | 5953b37130e2af4a1cd7ebd5f80784962e97b750 /Modules/posixmodule.c | |
parent | d0b8e83dc5b92e71d08d39298641d679be419dd8 (diff) | |
download | cpython-94785ef14294e9d924c9ceee3d6f9082d4555f28.zip cpython-94785ef14294e9d924c9ceee3d6f9082d4555f28.tar.gz cpython-94785ef14294e9d924c9ceee3d6f9082d4555f28.tar.bz2 |
Correct implementation and documentation of os.confstr. Add a simple test
case. I've yet to figure out how to provoke a None return I can test.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r-- | Modules/posixmodule.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index d91d8b5..4c462a0 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -6817,15 +6817,18 @@ posix_confstr(PyObject *self, PyObject *args) errno = 0; len = confstr(name, buffer, sizeof(buffer)); - if (len == -1) { - posix_error(); - } - else if (len == 0) { - result = PyString_FromString(""); + if (len == 0) { + if (errno) { + posix_error(); + } + else { + result = Py_None; + Py_INCREF(Py_None); + } } else { if ((unsigned int)len >= sizeof(buffer)) { - result = PyString_FromStringAndSize(NULL, len); + result = PyString_FromStringAndSize(NULL, len+1); if (result != NULL) confstr(name, PyString_AS_STRING(result), len+1); } |