diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -6267,18 +6267,22 @@ Perform a statvfs system call on the giv static PyObject * posix_statvfs(PyObject *self, PyObject *args) { + PyObject *opath, *result = NULL; char *path; int res; struct statvfs st; - if (!PyArg_ParseTuple(args, "s:statvfs", &path)) - return NULL; + if (!PyArg_ParseTuple(args, "O&:statvfs", PyUnicode_FSConverter, &opath)) + return NULL; + path = PyBytes_AS_STRING(opath); Py_BEGIN_ALLOW_THREADS res = statvfs(path, &st); Py_END_ALLOW_THREADS if (res != 0) - return posix_error_with_filename(path); - - return _pystatvfs_fromstructstatvfs(st); + result = posix_error_with_filename(path); + else + result = _pystatvfs_fromstructstatvfs(st); + Py_DECREF(opath); + return result; } #endif /* HAVE_STATVFS */