Title: Should PyLong_AsLongAndOverflow raise exception on overflow?
Type: behavior Stage: resolved
Components: C API Versions: Python 3.10
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: ZackerySpytz, ganesh3597, mark.dickinson, serhiy.storchaka
Priority: normal Keywords:

Created on 2020-12-17 08:52 by ganesh3597, last changed 2020-12-19 04:20 by ganesh3597. This issue is now closed.

Messages (4)
msg383225 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-12-17 09:44
No, it should not.
msg383227 - (view) Author: Zackery Spytz (ZackerySpytz) * (Python triager) Date: 2020-12-17 10:32
> No, it should not.

I agree.
msg383300 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2020-12-18 14:10
@ganesh3597. PyLong_AsLongAndOverflow is behaving as intended, and changes to the behaviour would break existing code.

If you think there's a case for changing the behaviour, you'd need to provide your rationale for the change, details of what you propose as the new behaviour and what steps you'd take for backwards compatibility.

If you were confused by the documentation, please identify which part of the documentation was misleading, and we can look into whether it needs fixing.
msg383357 - (view) Author: Ganesh Kathiresan (ganesh3597) Date: 2020-12-19 04:20
Hi All, thanks for the input. Yeah, the current behavior makes sense, if overflow exception is needed, we can use PyLong_AsLong. I guess my confusion was from the doc: 
> set *overflow to 1 or -1, respectively, and return -1;
> Returns -1 on error. Use PyErr_Occurred() to disambiguate.

It's not particularly clear if overflow is an `error` here, but again a quick compile and run will give you the answer. You can take a call if we have to have an explicit statement saying: no exception raised on overflow
Date User Action Args
2020-12-19 04:20:07ganesh3597setmessages: + msg383357
2020-12-18 14:10:09mark.dickinsonsetstatus: open -> closed

nosy: + mark.dickinson
messages: + msg383300

resolution: not a bug
stage: resolved
2020-12-17 10:32:34ZackerySpytzsetnosy: + ZackerySpytz
messages: + msg383227
2020-12-17 09:44:01serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg383225
2020-12-17 08:52:53ganesh3597create