Changeset 391 for python/trunk/Modules/grpmodule.c
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Modules/grpmodule.c
r2 r391 4 4 #include "Python.h" 5 5 #include "structseq.h" 6 7 #include <sys/types.h> 6 #include "posixmodule.h" 7 8 8 #include <grp.h> 9 9 … … 11 11 {"gr_name", "group name"}, 12 12 {"gr_passwd", "password"}, 13 {"gr_gid", "group id"}, 14 {"gr_mem", "group mem ebers"},13 {"gr_gid", "group id"}, 14 {"gr_mem", "group members"}, 15 15 {0} 16 16 }; … … 71 71 } 72 72 #endif 73 SET(setIndex++, PyInt_FromLong((long)p->gr_gid));73 SET(setIndex++, _PyInt_FromGid(p->gr_gid)); 74 74 SET(setIndex++, w); 75 75 #undef SET … … 87 87 { 88 88 PyObject *py_int_id; 89 unsigned int gid;89 gid_t gid; 90 90 struct group *p; 91 91 92 92 py_int_id = PyNumber_Int(pyo_id); 93 93 if (!py_int_id) 94 return NULL; 95 gid = PyInt_AS_LONG(py_int_id); 94 return NULL; 95 if (!_Py_Gid_Converter(py_int_id, &gid)) { 96 Py_DECREF(py_int_id); 97 return NULL; 98 } 96 99 Py_DECREF(py_int_id); 97 100 98 101 if ((p = getgrgid(gid)) == NULL) { 99 PyErr_Format(PyExc_KeyError, "getgrgid(): gid not found: %d", gid); 102 if (gid < 0) 103 PyErr_Format(PyExc_KeyError, 104 "getgrgid(): gid not found: %ld", (long)gid); 105 else 106 PyErr_Format(PyExc_KeyError, 107 "getgrgid(): gid not found: %lu", (unsigned long)gid); 100 108 return NULL; 101 109 } … … 114 122 return NULL; 115 123 name = PyString_AS_STRING(py_str_name); 116 124 117 125 if ((p = getgrnam(name)) == NULL) { 118 126 PyErr_Format(PyExc_KeyError, "getgrnam(): name not found: %s", name); … … 159 167 {"getgrall", grp_getgrall, METH_NOARGS, 160 168 "getgrall() -> list of tuples\n\ 161 Return a list of all available group entries, in arbitrary order."}, 169 Return a list of all available group entries, in arbitrary order.\n\ 170 An entry whose name starts with '+' or '-' represents an instruction\n\ 171 to use YP/NIS and may not be accessible via getgrnam or getgrgid."}, 162 172 {NULL, NULL} /* sentinel */ 163 173 };
Note:
See TracChangeset
for help on using the changeset viewer.