Message289691
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
type).
as Serhiy mentioned in http://bugs.python.org/issue15988#msg289679 and in
code review comments in https://github.com/python/cpython/pull/668, 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:21 | Oren Milman | set | recipients:
+ Oren Milman, terry.reedy, mark.dickinson, ezio.melotti, serhiy.storchaka |
2017-03-15 20:27:21 | Oren Milman | set | messageid: <1489609641.47.0.519228925309.issue15988@psf.upfronthosting.co.za> |
2017-03-15 20:27:21 | Oren Milman | link | issue15988 messages |
2017-03-15 20:27:21 | Oren Milman | create | |
|