summaryrefslogtreecommitdiff
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorSkip Montanaro <skip@pobox.com>2006-04-20 01:29:48 +0000
committerSkip Montanaro <skip@pobox.com>2006-04-20 01:29:48 +0000
commit94785ef14294e9d924c9ceee3d6f9082d4555f28 (patch)
tree5953b37130e2af4a1cd7ebd5f80784962e97b750 /Modules/posixmodule.c
parentd0b8e83dc5b92e71d08d39298641d679be419dd8 (diff)
downloadcpython-git-94785ef14294e9d924c9ceee3d6f9082d4555f28.tar.gz
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.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index d91d8b5eec..4c462a039c 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);
}