Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Modules/grpmodule.c

    r2 r391  
    44#include "Python.h"
    55#include "structseq.h"
    6 
    7 #include <sys/types.h>
     6#include "posixmodule.h"
     7
    88#include <grp.h>
    99
     
    1111   {"gr_name", "group name"},
    1212   {"gr_passwd", "password"},
    13    {"gr_gid", "group id"}, 
    14    {"gr_mem", "group memebers"},
     13   {"gr_gid", "group id"},
     14   {"gr_mem", "group members"},
    1515   {0}
    1616};
     
    7171    }
    7272#endif
    73     SET(setIndex++, PyInt_FromLong((long) p->gr_gid));
     73    SET(setIndex++, _PyInt_FromGid(p->gr_gid));
    7474    SET(setIndex++, w);
    7575#undef SET
     
    8787{
    8888    PyObject *py_int_id;
    89     unsigned int gid;
     89    gid_t gid;
    9090    struct group *p;
    9191
    9292    py_int_id = PyNumber_Int(pyo_id);
    9393    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    }
    9699    Py_DECREF(py_int_id);
    97100
    98101    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);
    100108        return NULL;
    101109    }
     
    114122            return NULL;
    115123    name = PyString_AS_STRING(py_str_name);
    116    
     124
    117125    if ((p = getgrnam(name)) == NULL) {
    118126        PyErr_Format(PyExc_KeyError, "getgrnam(): name not found: %s", name);
     
    159167    {"getgrall",        grp_getgrall,   METH_NOARGS,
    160168     "getgrall() -> list of tuples\n\
    161 Return a list of all available group entries, in arbitrary order."},
     169Return a list of all available group entries, in arbitrary order.\n\
     170An entry whose name starts with '+' or '-' represents an instruction\n\
     171to use YP/NIS and may not be accessible via getgrnam or getgrgid."},
    162172    {NULL,              NULL}           /* sentinel */
    163173};
Note: See TracChangeset for help on using the changeset viewer.