This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Oren Milman
Recipients Oren Milman, ezio.melotti, mark.dickinson, serhiy.storchaka, terry.reedy
Date 2017-03-15.20:27:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
also, IMHO, we should open an issue named 'raise ValueError instead of OverflowError when a negative int is invalid', and leave for that
new issue some the changes (which you commented about in the PR).

I didn't want to open it without your approval.
here is what I thought should be the contents of the issue (feel
free to edit my draft as you wish and open the issue yourself,
if you think we should open it):

In various C functions, a negative int argument is invalid. in most of these
functions, ValueError is raised for a negative int, or at least for a small
negative int (i.e. a negative int that fits in some signed integer C

as Serhiy mentioned in and in
code review comments in, it might
be that a ValueError should always be raised in such functions, upon receiving
a negative int (even upon receiving a big negative int, such as (-1 << 1000)).

the following functions were identified as relevant only while working on
#15988, so there are probably (a lot?) more relevant functions.

functions where OverflowError is raised only for big negative ints:
    - Objects/bytesobject.c - bytes_new
    - Objects/bytearrayobject.c - bytearray_init
    - functions that would be fixed as part of #29819?
        * Modules/_io/stringio.c - _io_StringIO_truncate_impl
        * Modules/_io/bytesio.c - _io_BytesIO_truncate_impl

functions where OverflowError is raised for any negative int (so a change would
probably break some users code):
    - Objects/longobject.c:
        * PyLong_AsUnsignedLong
        * PyLong_AsSize_t
    - Modules/_ctypes/_ctypes.c - PyCArrayType_new

Note: while patching these functions, one should also make sure that the
patched functions produce consistent error messages, as explained in #15988
(in which it was decided to leave these functions (which currently produce
inconsistent error messages) to this issue.)
Date User Action Args
2017-03-15 20:27:21Oren Milmansetrecipients: + Oren Milman, terry.reedy, mark.dickinson, ezio.melotti, serhiy.storchaka
2017-03-15 20:27:21Oren Milmansetmessageid: <>
2017-03-15 20:27:21Oren Milmanlinkissue15988 messages
2017-03-15 20:27:21Oren Milmancreate