summaryrefslogtreecommitdiffstats
path: root/Modules/grpmodule.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-01-18 16:49:57 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-01-18 16:49:57 (GMT)
commit9cc4ed5c7a86b2aa58176222107dbb01d40a3680 (patch)
tree7a8e8b0a9ecf98a61a833e8fc6a0b69505d406c3 /Modules/grpmodule.c
parent9def2843873edde3feec6eaf2ee60c4e48172164 (diff)
downloadcpython-9cc4ed5c7a86b2aa58176222107dbb01d40a3680.zip
cpython-9cc4ed5c7a86b2aa58176222107dbb01d40a3680.tar.gz
cpython-9cc4ed5c7a86b2aa58176222107dbb01d40a3680.tar.bz2
Issue #26129: Deprecated accepting non-integers in grp.getgrgid().
Diffstat (limited to 'Modules/grpmodule.c')
-rw-r--r--Modules/grpmodule.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/Modules/grpmodule.c b/Modules/grpmodule.c
index 403e434..5ad87f1 100644
--- a/Modules/grpmodule.c
+++ b/Modules/grpmodule.c
@@ -100,14 +100,25 @@ grp_getgrgid_impl(PyModuleDef *module, PyObject *id)
gid_t gid;
struct group *p;
- py_int_id = PyNumber_Long(id);
- if (!py_int_id)
+ if (!_Py_Gid_Converter(id, &gid)) {
+ if (!PyErr_ExceptionMatches(PyExc_TypeError)) {
return NULL;
- if (!_Py_Gid_Converter(py_int_id, &gid)) {
+ }
+ PyErr_Clear();
+ if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
+ "group id must be int, not %.200",
+ id->ob_type->tp_name) < 0) {
+ return NULL;
+ }
+ py_int_id = PyNumber_Long(id);
+ if (!py_int_id)
+ return NULL;
+ if (!_Py_Gid_Converter(py_int_id, &gid)) {
+ Py_DECREF(py_int_id);
+ return NULL;
+ }
Py_DECREF(py_int_id);
- return NULL;
}
- Py_DECREF(py_int_id);
if ((p = getgrgid(gid)) == NULL) {
PyObject *gid_obj = _PyLong_FromGid(gid);