From: Serhiy Storchaka Date: Sun, 10 Feb 2013 20:03:08 +0000 (+0200) Subject: Issue #4591: Uid and gid values larger than 2**31 are supported now. X-Git-Tag: v3.4.0a1~1398 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c2d020090b324285bf144f29ac4da3771be7c40a;p=python Issue #4591: Uid and gid values larger than 2**31 are supported now. --- c2d020090b324285bf144f29ac4da3771be7c40a diff --cc Modules/posixmodule.c index 2e65da2a5f,7e36df5da6..2d31c94f80 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@@ -2896,24 -3211,23 +3020,26 @@@ Equivalent to os.chown(path, uid, gid, 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; + memset(&path, 0, sizeof(path)); + path.function_name = "lchown"; - if (!PyArg_ParseTuple(args, "O&ll:lchown", + if (!PyArg_ParseTuple(args, "O&O&O&:lchown", - PyUnicode_FSConverter, &opath, + path_converter, &path, - &uid, &gid)) + _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; }