[issue29834] Raise ValueError rather of OverflowError in PyLong_AsUnsignedLong()

2017-03-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: _Py_Uid_Converter() in Modules/posixmodule.c is not an example because it calls PyLong_AsUnsignedLong() only for positive integers > LONG_MAX. PyLong_AsUnsignedLong() is used not much. The motivation of this issue was that if use PyLong_AsUnsignedLong() for

[issue29834] Raise ValueError rather of OverflowError in PyLong_AsUnsignedLong()

2017-03-18 Thread Raymond Hettinger
Raymond Hettinger added the comment: Looking back in time, this API isn't as old as I thought. The other concerns about breaking a published API still stand. -- nosy: -gvanrossum ___ Python tracker

[issue29834] Raise ValueError rather of OverflowError in PyLong_AsUnsignedLong()

2017-03-18 Thread Raymond Hettinger
Raymond Hettinger added the comment: Strong -1 on this. For zero benefit, this breaks everything (within Python and third-party code) that ever relied on the documented behavior , https://docs.python.org/3/c-api/long.html#c.PyLong_AsUnsignedLong . The cause perfectly fits the definition of

[issue29834] Raise ValueError rather of OverflowError in PyLong_AsUnsignedLong()

2017-03-17 Thread Oren Milman
Oren Milman added the comment: note that there are functions that rely on the fact that PyLong_AsUnsignedLong currently raises OverflowError for both cases. such functions would probably use PyErr_ExceptionMatches(PyExc_OverflowError) or something like PyErr_GivenExceptionMatches(err,

[issue29834] Raise ValueError rather of OverflowError in PyLong_AsUnsignedLong()

2017-03-17 Thread Serhiy Storchaka
New submission from Serhiy Storchaka: OverflowError is raised when Python integer doesn't fit in C integer type due to platform limitations. Different platforms have different limits. But in PyLong_AsUnsignedLong() only the upper limit is platform-depended. Negative integers always are not