summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-01-01 22:05:55 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-01-01 22:05:55 (GMT)
commite4110dc11f9e90d3a7fcd8f0a5f9ded344f433c6 (patch)
treeee1a8b42b8180f001903e511364ea187e1f8dff6 /Modules/posixmodule.c
parent8c126d7abd67fbb88a58d0efbdad573fc6043e76 (diff)
downloadcpython-e4110dc11f9e90d3a7fcd8f0a5f9ded344f433c6.zip
cpython-e4110dc11f9e90d3a7fcd8f0a5f9ded344f433c6.tar.gz
cpython-e4110dc11f9e90d3a7fcd8f0a5f9ded344f433c6.tar.bz2
Issue #9644: Fix the encoding used by os.statvfs(): use the filesystem encoding
with the surrogateescape error handler, instead of UTF-8 in strict mode.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 0d2919b..e7e5305 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -6463,18 +6463,22 @@ Perform a statvfs system call on the given path.");
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))
+ 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 posix_error_with_allocated_filename(opath);
- return _pystatvfs_fromstructstatvfs(st);
+ result = _pystatvfs_fromstructstatvfs(st);
+ Py_DECREF(opath);
+ return result;
}
#endif /* HAVE_STATVFS */