summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-09-20 02:04:33 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-09-20 02:04:33 (GMT)
commit6fa67775033d99a8a0e5b978d37ef00aed6c1fbe (patch)
treec141782509e5c7f82dd288c169646c16bfaf11e3 /Modules
parent8f53d092f23d063b19a9377fbb7d1d2f62ad77c9 (diff)
downloadcpython-6fa67775033d99a8a0e5b978d37ef00aed6c1fbe.zip
cpython-6fa67775033d99a8a0e5b978d37ef00aed6c1fbe.tar.gz
cpython-6fa67775033d99a8a0e5b978d37ef00aed6c1fbe.tar.bz2
os.statvfs() encodes the filename to the filesystem encoding
Diffstat (limited to 'Modules')
-rw-r--r--Modules/posixmodule.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 2fc509d..25e7f0d 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -8071,16 +8071,20 @@ Perform a statvfs system call on the given path.");
static PyObject *
posix_statvfs(PyObject *self, PyObject *args)
{
- char *path;
+ PyObject *path;
int res;
struct statvfs st;
- if (!PyArg_ParseTuple(args, "s:statvfs", &path))
+ if (!PyArg_ParseTuple(args, "O&:statvfs", PyUnicode_FSConverter, &path))
return NULL;
Py_BEGIN_ALLOW_THREADS
- res = statvfs(path, &st);
+ res = statvfs(PyBytes_AS_STRING(path), &st);
Py_END_ALLOW_THREADS
- if (res != 0)
- return posix_error_with_filename(path);
+ if (res != 0) {
+ posix_error_with_filename(PyBytes_AS_STRING(path));
+ Py_DECREF(path);
+ return NULL;
+ }
+ Py_DECREF(path);
return _pystatvfs_fromstructstatvfs(st);
}