
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2016-09-08 12:48 byStyXman, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| fix_28019.diff | StyXman,2016-09-08 14:22 | review | ||
| fix_28019.diff | StyXman,2016-09-08 15:08 | review | ||
| itertools_count_truncated_step.patch | serhiy.storchaka,2016-09-08 17:57 | review | ||
| Messages (6) | |||
|---|---|---|---|
| msg275007 -(view) | Author: Marcos Dione (StyXman)* | Date: 2016-09-08 12:48 | |
If the `step` parameter for `itertools.count()` rounds to 1 (f.i., 1.1, 1.437643, 1.99999), then it fallsback to fast (integer) mode and increases the counter by 1. Here's an example:Python 3.6.0a4+ (default:ddc95a9bc2e0+, Sep 8 2016, 14:46:19)>>> import itertools>>> for i in itertools.count(1, step=1.5):... print(i)... if i > 10:... break1234567891011 | |||
| msg275016 -(view) | Author: Marcos Dione (StyXman)* | Date: 2016-09-08 14:22 | |
Here's a first approach on fixing this bug. I'm not sure how to handle the case where step=1.0. | |||
| msg275025 -(view) | Author: Facundo Batista (facundobatista)*![]() | Date: 2016-09-08 14:43 | |
I think the fix nails it; all the problem was that the "fast" mode was wrongly detected, and all the problems (counting badly, or a bad repr, etc) is a problem after setting cnt into PY_SSIZE_T_MAX.IIUC there is nothing special to do when step=1.0, as later on the original objects are used (they don't suffer a wrong cast to integer anymore). | |||
| msg275038 -(view) | Author: Marcos Dione (StyXman)* | Date: 2016-09-08 15:08 | |
New patch following comments from SilentGhost. | |||
| msg275082 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2016-09-08 17:57 | |
PyLong_AsLong() not just converts Python integer to C long, but it also converts Python float to Python integer (with the lost of the fractional part). We need to check that the value is Python integer.Here is a patch that fixes this issue and few other bugs. | |||
| msg275583 -(view) | Author: Roundup Robot (python-dev)![]() | Date: 2016-09-10 06:54 | |
New changesetb23f963a7b45 by Serhiy Storchaka in branch '3.5':Issue#28019: itertools.count() no longer rounds non-integer step in rangehttps://hg.python.org/cpython/rev/b23f963a7b45New changeset74667320778e by Serhiy Storchaka in branch '2.7':Issue#28019: Backported additional tests for itertools.count().https://hg.python.org/cpython/rev/74667320778eNew changeset51dfab4f28e7 by Serhiy Storchaka in branch 'default':Issue#28019: itertools.count() no longer rounds non-integer step in rangehttps://hg.python.org/cpython/rev/51dfab4f28e7 | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:36 | admin | set | github: 72206 |
| 2016-09-10 07:11:34 | serhiy.storchaka | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2016-09-10 06:54:45 | python-dev | set | nosy: +python-dev messages: +msg275583 |
| 2016-09-08 20:51:43 | rhettinger | set | assignee:rhettinger ->serhiy.storchaka |
| 2016-09-08 17:57:08 | serhiy.storchaka | set | files: +itertools_count_truncated_step.patch versions: - Python 3.3, Python 3.4 nosy: +serhiy.storchaka messages: +msg275082 stage: commit review -> patch review |
| 2016-09-08 16:08:23 | StyXman | set | versions: + Python 3.3, Python 3.4 |
| 2016-09-08 15:43:00 | SilentGhost | set | stage: patch review -> commit review |
| 2016-09-08 15:08:25 | StyXman | set | files: +fix_28019.diff messages: +msg275038 |
| 2016-09-08 14:59:26 | rhettinger | set | assignee:rhettinger |
| 2016-09-08 14:43:21 | facundobatista | set | nosy: +facundobatista messages: +msg275025 |
| 2016-09-08 14:34:26 | SilentGhost | set | stage: patch review versions: - Python 3.3, Python 3.4 |
| 2016-09-08 14:25:15 | StyXman | set | versions: + Python 3.3, Python 3.4 |
| 2016-09-08 14:22:46 | StyXman | set | files: +fix_28019.diff keywords: +patch messages: +msg275016 |
| 2016-09-08 12:56:03 | facundobatista | set | versions: + Python 3.5 |
| 2016-09-08 12:51:07 | serhiy.storchaka | set | nosy: +rhettinger |
| 2016-09-08 12:48:32 | StyXman | create | |