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.
Created on 2016年09月08日 12:48 by StyXman, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| 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: ... break 1 2 3 4 5 6 7 8 9 10 11 |
|||
| 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) * (Python committer) | 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) * (Python committer) | 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) (Python triager) | Date: 2016年09月10日 06:54 | |
New changeset b23f963a7b45 by Serhiy Storchaka in branch '3.5': Issue #28019: itertools.count() no longer rounds non-integer step in range https://hg.python.org/cpython/rev/b23f963a7b45 New changeset 74667320778e by Serhiy Storchaka in branch '2.7': Issue #28019: Backported additional tests for itertools.count(). https://hg.python.org/cpython/rev/74667320778e New changeset 51dfab4f28e7 by Serhiy Storchaka in branch 'default': Issue #28019: itertools.count() no longer rounds non-integer step in range https://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 | |