static PyObject *
posix_lchown(PyObject *self, PyObject *args)
{
- PyObject *opath;
- char *path;
+ path_t path;
- long uid, gid;
+ uid_t uid;
+ gid_t gid;
int res;
- if (!PyArg_ParseTuple(args, "O&ll:lchown",
+ memset(&path, 0, sizeof(path));
+ path.function_name = "lchown";
- PyUnicode_FSConverter, &opath,
+ if (!PyArg_ParseTuple(args, "O&O&O&:lchown",
- &uid, &gid))
+ path_converter, &path,
+ _Py_Uid_Converter, &uid,
+ _Py_Gid_Converter, &gid))
return NULL;
- path = PyBytes_AsString(opath);
Py_BEGIN_ALLOW_THREADS
- res = lchown(path.narrow, (uid_t) uid, (gid_t) gid);
- res = lchown(path, uid, gid);
++ res = lchown(path.narrow, uid, gid);
Py_END_ALLOW_THREADS
- if (res < 0)
- return posix_error_with_allocated_filename(opath);
- Py_DECREF(opath);
+ if (res < 0) {
+ path_error(&path);
+ path_cleanup(&path);
+ return NULL;
+ }
+ path_cleanup(&path);
Py_INCREF(Py_None);
return Py_None;
}