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.

classification
Title: set stop default to -PY_SSIZE_T_MAX-1 in PySlice_Unpack
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.7, Python 3.6, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: mark.dickinson, serhiy.storchaka, vstinner, xiang.zhang
Priority: normal Keywords:

Created on 2017-05-05 10:47 by xiang.zhang, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 1480 merged xiang.zhang, 2017-05-05 10:50
PR 1529 merged xiang.zhang, 2017-05-10 10:33
PR 1530 merged xiang.zhang, 2017-05-10 10:33
PR 1531 merged xiang.zhang, 2017-05-10 10:36
Messages (8)
msg293097 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2017-05-05 10:47
The default value for stop in PySlice_Unpack should be -PY_SSIZE_T_MAX-1. Otherwise a sequence of length PY_SSIZE_T_MAX could get a wrong slicelength when doing L[::-1].
msg293098 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-05-05 10:56
I'm not sure that -PY_SSIZE_T_MAX-1 always is representable. I would use PY_SSIZE_T_MIN and add a static assert (Py_BUILD_ASSERT) that PY_SSIZE_T_MIN + 1 <= -PY_SSIZE_T_MAX. Actually currently PY_SSIZE_T_MIN is -PY_SSIZE_T_MAX-1 by definition, but this can be changed in future.
msg293101 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-05 11:54
Hum, integer overflows are complex issues. It deserves an unit test, maybe even in C written in _testcapi?
msg293116 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2017-05-05 16:02
I am okay to use PY_SSIZE_T_MIN. But if we are worried about future change of PY_SSIZE_T_MIN, seems we also need to change the API doc of PySlice_Unpack(). Although _PyEval_SliceIndex's comment says it clips value to -PY_SSIZE_T_MAX-1, actually it uses PyNumber_AsSize_t and clips value to PY_SSIZE_T_MIN.
msg293396 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2017-05-10 10:19
New changeset 2ddf5a19c3a06978edff2c8ba0aaf5df3528204a by Xiang Zhang in branch 'master':
bpo-30281: Fix the default value for stop in PySlice_Unpack() (#1480)
https://github.com/python/cpython/commit/2ddf5a19c3a06978edff2c8ba0aaf5df3528204a
msg293399 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2017-05-10 11:00
New changeset 98b49a00d413972965044fd355be3b8482caa07c by Xiang Zhang in branch '3.6':
bpo-30281: Fix the default value for stop in PySlice_Unpack() (#1480) (#1529)
https://github.com/python/cpython/commit/98b49a00d413972965044fd355be3b8482caa07c
msg293400 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2017-05-10 11:11
New changeset 639e295650a51894412c9d976958792010d3bcf8 by Xiang Zhang in branch '3.5':
bpo-30281: Fix the default value for stop in PySlice_Unpack() (#1530) (#1480https://github.com/python/cpython/commit/639e295650a51894412c9d976958792010d3bcf8
msg293402 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2017-05-10 11:20
New changeset 05469fa1c05acf55bdca05db21822ecdd7f6487a by Xiang Zhang in branch '2.7':
bpo-30281: Fix the default value for stop in PySlice_Unpack() (#1531) (#1480)
https://github.com/python/cpython/commit/05469fa1c05acf55bdca05db21822ecdd7f6487a
History
Date User Action Args
2022-04-11 14:58:46adminsetgithub: 74467
2017-05-10 11:21:37xiang.zhangsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2017-05-10 11:20:31xiang.zhangsetmessages: + msg293402
2017-05-10 11:11:11xiang.zhangsetmessages: + msg293400
2017-05-10 11:00:18xiang.zhangsetmessages: + msg293399
2017-05-10 10:36:32xiang.zhangsetpull_requests: + pull_request1630
2017-05-10 10:33:45xiang.zhangsetpull_requests: + pull_request1629
2017-05-10 10:33:06xiang.zhangsetpull_requests: + pull_request1628
2017-05-10 10:19:44xiang.zhangsetmessages: + msg293396
2017-05-05 16:02:36xiang.zhangsetmessages: + msg293116
2017-05-05 11:54:51vstinnersetnosy: + vstinner
messages: + msg293101
2017-05-05 10:56:04serhiy.storchakasetnosy: + mark.dickinson
messages: + msg293098
2017-05-05 10:50:02xiang.zhangsetpull_requests: + pull_request1579
2017-05-05 10:47:45xiang.zhangcreate