--- ../Python-3.1.1/Modules/posixmodule.c 2009-05-29 16:47:46.000000000 +0200 +++ Modules/posixmodule.c 2009-12-22 05:35:38.000000000 +0100 @@ -5261,12 +5261,16 @@ posix_mkfifo(PyObject *self, PyObject *args) { + PyObject *py_filename; char *filename; int mode = 0666; int res; - if (!PyArg_ParseTuple(args, "s|i:mkfifo", &filename, &mode)) + if (!PyArg_ParseTuple(args, "O&|i:mkfifo", PyUnicode_FSConverter, + &py_filename, &mode)) return NULL; + filename = bytes2str(py_filename, 1); Py_BEGIN_ALLOW_THREADS res = mkfifo(filename, mode); Py_END_ALLOW_THREADS + release_bytes(py_filename); if (res < 0) return posix_error(); @@ -5291,13 +5295,17 @@ posix_mknod(PyObject *self, PyObject *args) { + PyObject *py_filename; char *filename; int mode = 0600; int device = 0; int res; - if (!PyArg_ParseTuple(args, "s|ii:mknod", &filename, &mode, &device)) + if (!PyArg_ParseTuple(args, "O&|ii:mknod", PyUnicode_FSConverter, + &py_filename, &mode, &device)) return NULL; + filename = bytes2str(py_filename, 1); Py_BEGIN_ALLOW_THREADS res = mknod(filename, mode, device); Py_END_ALLOW_THREADS + release_bytes(py_filename); if (res < 0) return posix_error(); @@ -5779,14 +5787,18 @@ posix_statvfs(PyObject *self, PyObject *args) { + PyObject *py_path; char *path; int res; struct statvfs st; - if (!PyArg_ParseTuple(args, "s:statvfs", &path)) + if (!PyArg_ParseTuple(args, "O&:statvfs", PyUnicode_FSConverter, + &py_path)) return NULL; + path = bytes2str(py_path, 1); Py_BEGIN_ALLOW_THREADS res = statvfs(path, &st); Py_END_ALLOW_THREADS if (res != 0) - return posix_error_with_filename(path); + return posix_error_with_allocated_filename(py_path); + release_bytes(py_path); return _pystatvfs_fromstructstatvfs(st); @@ -5954,21 +5966,25 @@ PyObject *result = NULL; int name; + PyObject *py_path; char *path; - if (PyArg_ParseTuple(args, "sO&:pathconf", &path, + if (PyArg_ParseTuple(args, "O&O&:pathconf", PyUnicode_FSConverter, &py_path, conv_path_confname, &name)) { long limit; - + path = bytes2str(py_path, 1); errno = 0; limit = pathconf(path, name); if (limit == -1 && errno != 0) { - if (errno == EINVAL) + if (errno == EINVAL) { /* could be a path or name problem */ + release_bytes(py_path); posix_error(); - else - posix_error_with_filename(path); + } else + posix_error_with_allocated_filename(py_path); } - else + else { + release_bytes(py_path); result = PyLong_FromLong(limit); + } } return result;