[Python-checkins] r84062 - in python/branches/py3k: Misc/NEWS Modules/posixmodule.c

victor.stinner python-checkins at python.org
Sun Aug 15 11:22:44 CEST 2010


Author: victor.stinner
Date: Sun Aug 15 11:22:44 2010
New Revision: 84062

Log:
Issue #9604: posix.initgroups() encodes the username using the fileystem
encoding and surrogateescape error handler. Patch written by David Watson.


Modified:
   python/branches/py3k/Misc/NEWS
   python/branches/py3k/Modules/posixmodule.c

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Sun Aug 15 11:22:44 2010
@@ -83,6 +83,9 @@
 Library
 -------
 
+- Issue #9604: posix.initgroups() encodes the username using the fileystem
+  encoding and surrogateescape error handler. Patch written by David Watson.
+
 - Issue #9603: posix.ttyname() and posix.ctermid() decode the terminal name
   using the filesystem encoding and surrogateescape error handler. Patch
   written by David Watson.

Modified: python/branches/py3k/Modules/posixmodule.c
==============================================================================
--- python/branches/py3k/Modules/posixmodule.c	(original)
+++ python/branches/py3k/Modules/posixmodule.c	Sun Aug 15 11:22:44 2010
@@ -4249,13 +4249,19 @@
 static PyObject *
 posix_initgroups(PyObject *self, PyObject *args)
 {
+    PyObject *oname;
     char *username;
+    int res;
     long gid;
 
-    if (!PyArg_ParseTuple(args, "sl:initgroups", &username, &gid))
+    if (!PyArg_ParseTuple(args, "O&l:initgroups",
+                          PyUnicode_FSConverter, &oname, &gid))
         return NULL;
+    username = PyBytes_AS_STRING(oname);
 
-    if (initgroups(username, (gid_t) gid) == -1)
+    res = initgroups(username, (gid_t) gid);
+    Py_DECREF(oname);
+    if (res == -1)
         return PyErr_SetFromErrno(PyExc_OSError);
 
     Py_INCREF(Py_None);


More information about the Python-checkins mailing list