[issue6305] islice doesn't accept large stop values
Alok Singhal added the comment: I started working on this bug as a part of PyCon US 2014 sprints. Should the bugfix include a fast path (basically the current implementation) for when the values involved can fit in an int, and a slow path for larger values? Or should the bugfix just have one path which works for all the cases (using PyObject * for "next", "stop" etc.)? -- nosy: +AlokSinghal ___ Python tracker <http://bugs.python.org/issue6305> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6305] islice doesn't accept large stop values
Alok Singhal added the comment: OK. I have written the "slow path" version and tested it a bit. I will add the code to switch between the paths and also add test cases as well. Thanks! -- ___ Python tracker <http://bugs.python.org/issue6305> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6305] islice doesn't accept large stop values
Alok Singhal added the comment: Here's a proposed patch. I need more tests for large values, but all the tests I could think of take a long time to get to a long value. I added some tests that don't take much time but work correctly for long values. If anyone has any ideas for some other tests, please let me know. -- keywords: +patch Added file: http://bugs.python.org/file34967/islice_large_values.patch ___ Python tracker <http://bugs.python.org/issue6305> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6305] islice doesn't accept large stop values
Alok Singhal added the comment: This updated patch has support for starting in fast mode until the next count would result in overflow in Py_ssize_t. The first patch started in slow mode as soon as any of 'start', 'stop', or 'step' was outside of the range. With this patch, we start in fast mode if possible and then transition to slow mode when needed. I also tested this patch for correctness for the following cases: - starting in slow mode, - transition from fast -> slow, - pickle/unpickle I did this by temporarily changing the code twice: - to always use fast mode, and - pretending that overflow occurs at value 5 instead of PY_SSIZE_T_MAX. -- Added file: http://bugs.python.org/file34996/islice_large_values-2.patch ___ Python tracker <http://bugs.python.org/issue6305> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6305] islice doesn't accept large stop values
Alok Singhal added the comment: OK. Here is the first patch with a couple of bug fixes for "slow mode". -- Added file: http://bugs.python.org/file34999/islice_large_values-3.patch ___ Python tracker <http://bugs.python.org/issue6305> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6305] islice doesn't accept large stop values
Alok Singhal added the comment: Uploading another patch which is the same as the last patch but this one applies cleanly after the latest islice changes for #21321. -- Added file: http://bugs.python.org/file35205/islice_large_values-4.patch ___ Python tracker <http://bugs.python.org/issue6305> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6305] islice doesn't accept large stop values
Alok Singhal added the comment: Yes, I signed it a few days ago. -- ___ Python tracker <http://bugs.python.org/issue6305> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6305] islice doesn't accept large stop values
Alok Singhal added the comment: Hi Raymond, Martin, I won't feel bad about this patch not making it into the final Python distribution. I worked on this bug because it was the only "core C" bug at PyCon US sprints for CPython. I learned a bit more about CPython while working on it and I don't consider the time I spent on this bug as wasted. Other than symmetry arguments, I can't think of any other argument for islice to accept large values. a = [] a[sys.maxsize+2:] # gives: [] islice(a, None, sys.maxsize+2) # raises exception But because islice has to go through the elements of the iterable from the current value to "start", while the first example doesn't, I don't think the symmetry argument is that strong here. So, I think it's fine if we close this bug without accepting this patch. Thanks for your time in reviewing it! -- ___ Python tracker <http://bugs.python.org/issue6305> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26083] ValueError: insecure string pickle in subprocess.Popen on Python 2
Alok Singhal added the comment: I think there is a small problem with the fix in changeset 268d13c7e939 (msg258029). It copies the string from the return value of _eintr_retry_call() twice. I am attaching a trivial fix. -- keywords: +patch nosy: +AlokSinghal Added file: http://bugs.python.org/file43034/subprocess.patch ___ Python tracker <http://bugs.python.org/issue26083> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com