summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-05-10 18:04:33 (GMT)
committerGuido van Rossum <guido@python.org>2007-05-10 18:04:33 (GMT)
commitbce56a6c5ba368c3cb84da315266ce975005f82c (patch)
treea49e74e73df59770d7822791977331149ea84444 /Modules/posixmodule.c
parent3b116a3187705fd04bb16bf5028d21ca14284249 (diff)
downloadcpython-bce56a6c5ba368c3cb84da315266ce975005f82c.zip
cpython-bce56a6c5ba368c3cb84da315266ce975005f82c.tar.gz
cpython-bce56a6c5ba368c3cb84da315266ce975005f82c.tar.bz2
Fix some miscellaneous places that incorrectly insisted on str8.
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 f5106e1..425fa5a 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -6966,13 +6966,19 @@ conv_confname(PyObject *arg, int *valuep, struct constdef *table,
*valuep = PyInt_AS_LONG(arg);
return 1;
}
- if (PyString_Check(arg)) {
+ else {
/* look up the value in the table using a binary search */
size_t lo = 0;
size_t mid;
size_t hi = tablesize;
int cmp;
- char *confname = PyString_AS_STRING(arg);
+ const char *confname;
+ Py_ssize_t namelen;
+ if (PyObject_AsCharBuffer(arg, &confname, &namelen) < 0) {
+ PyErr_SetString(PyExc_TypeError,
+ "configuration names must be strings or integers");
+ return 0;
+ }
while (lo < hi) {
mid = (lo + hi) / 2;
cmp = strcmp(confname, table[mid].name);
@@ -6986,11 +6992,8 @@ conv_confname(PyObject *arg, int *valuep, struct constdef *table,
}
}
PyErr_SetString(PyExc_ValueError, "unrecognized configuration name");
+ return 0;
}
- else
- PyErr_SetString(PyExc_TypeError,
- "configuration names must be strings or integers");
- return 0;
}