[issue5377] Strange behavior when performing int on a Decimal made from -sys.maxint-1

STINNER Victor report at bugs.python.org
Sun Mar 29 13:38:43 CEST 2009


STINNER Victor <victor.stinner at haypocalc.com> added the comment:

> I'm still not sure why anyone would care about getting longs
> instead of ints back from int(x)

It's strange that sometimes we need to write int(int(obj)) to get an
integer :-/ I usually use int(x) to convert x to an integer (type 'int'
and not 'long').

> (0) Please could you add some tests!

done

> (1) Shouldn't the first line you added include a check 
> for res == NULL?  

segfault... ooops :-) fixed

> (2) It looks as though the patched code ends up calling 
> PyLong_Check twice (...)

done

See updated patch.

----------
Added file: http://bugs.python.org/file13455/force_int-2.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5377>
_______________________________________


More information about the Python-bugs-list mailing list