Mercurial > cpython-lru_cache-weakref
changeset 82148:3fdcffdfd3e6
Reject float as uid or gid.
A regression was introduced in the commit for issue #4591.
| author | Serhiy Storchaka <storchaka@gmail.com> |
|---|---|
| date | Sun, 10 Feb 2013 23:28:33 +0200 |
| parents | 94256de0aff0 (current diff) 4ef048f4834e (diff) |
| children | b53b029895df |
| files | Modules/posixmodule.c |
| diffstat | 1 files changed, 14 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/Modules/posixmodule.c Sun Feb 10 22:03:08 2013 +0200 +++ b/Modules/posixmodule.c Sun Feb 10 23:28:33 2013 +0200 @@ -406,7 +406,13 @@ _Py_Uid_Converter(PyObject *obj, void *p) { int overflow; - long result = PyLong_AsLongAndOverflow(obj, &overflow); + long result; + if (PyFloat_Check(obj)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float"); + return 0; + } + result = PyLong_AsLongAndOverflow(obj, &overflow); if (overflow < 0) goto OverflowDown; if (!overflow && result == -1) { @@ -454,7 +460,13 @@ _Py_Gid_Converter(PyObject *obj, void *p) { int overflow; - long result = PyLong_AsLongAndOverflow(obj, &overflow); + long result; + if (PyFloat_Check(obj)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float"); + return 0; + } + result = PyLong_AsLongAndOverflow(obj, &overflow); if (overflow < 0) goto OverflowDown; if (!overflow && result == -1) {
