A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2013-February/123934.html below:

Reject float as uid or gid.

[Python-Dev] [Python-checkins] cpython (3.3): Reject float as uid or gid.Eric V. Smith eric at trueblade.com
Mon Feb 11 00:06:35 CET 2013
On 2/10/2013 4:29 PM, serhiy.storchaka wrote:
> http://hg.python.org/cpython/rev/4ef048f4834e
> changeset:   82147:4ef048f4834e
> branch:      3.3
> parent:      82145:b322655a4a88
> user:        Serhiy Storchaka <storchaka at gmail.com>
> date:        Sun Feb 10 23:28:02 2013 +0200
> summary:
>   Reject float as uid or gid.
> A regression was introduced in the commit for issue issue #4591.
> 
> files:
>   Modules/posixmodule.c |  16 ++++++++++++++--
>   1 files changed, 14 insertions(+), 2 deletions(-)
> 
> 
> diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
> --- a/Modules/posixmodule.c
> +++ b/Modules/posixmodule.c
> @@ -437,7 +437,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) {

Instead of special-casing float, isn't using __index__ the preferred way
to do this?

-- 
Eric.
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4