aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-01-18 18:49:57 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2016-01-18 18:49:57 +0200
commit9cc4ed5c7a86b2aa58176222107dbb01d40a3680 (patch)
tree7a8e8b0a9ecf98a61a833e8fc6a0b69505d406c3 /Modules/grpmodule.c
parentsubprocess._optim_args_from_interpreter_flags() (diff)
downloadcpython-9cc4ed5c7a86b2aa58176222107dbb01d40a3680.tar.gz
cpython-9cc4ed5c7a86b2aa58176222107dbb01d40a3680.tar.bz2
cpython-9cc4ed5c7a86b2aa58176222107dbb01d40a3680.zip
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 403e434697b..5ad87f1ca8a 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);