[issue28019] itertools.count() falls back to fast (integer) mode when step rounds to 1

2016-09-10 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28019] itertools.count() falls back to fast (integer) mode when step rounds to 1

2016-09-10 Thread Roundup Robot

Roundup Robot added the comment:

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

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28019] itertools.count() falls back to fast (integer) mode when step rounds to 1

2016-09-08 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee: rhettinger -> serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28019] itertools.count() falls back to fast (integer) mode when step rounds to 1

2016-09-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

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.

--
nosy: +serhiy.storchaka
stage: commit review -> patch review
versions:  -Python 3.3, Python 3.4
Added file: 
http://bugs.python.org/file44471/itertools_count_truncated_step.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28019] itertools.count() falls back to fast (integer) mode when step rounds to 1

2016-09-08 Thread Marcos Dione

Changes by Marcos Dione :


--
versions: +Python 3.3, Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28019] itertools.count() falls back to fast (integer) mode when step rounds to 1

2016-09-08 Thread SilentGhost

Changes by SilentGhost :


--
stage: patch review -> commit review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28019] itertools.count() falls back to fast (integer) mode when step rounds to 1

2016-09-08 Thread Marcos Dione

Marcos Dione added the comment:

New patch following comments from SilentGhost.

--
Added file: http://bugs.python.org/file44467/fix_28019.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28019] itertools.count() falls back to fast (integer) mode when step rounds to 1

2016-09-08 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee:  -> rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28019] itertools.count() falls back to fast (integer) mode when step rounds to 1

2016-09-08 Thread Facundo Batista

Facundo Batista added the comment:

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).

--
nosy: +facundobatista

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28019] itertools.count() falls back to fast (integer) mode when step rounds to 1

2016-09-08 Thread SilentGhost

Changes by SilentGhost :


--
stage:  -> patch review
versions:  -Python 3.3, Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28019] itertools.count() falls back to fast (integer) mode when step rounds to 1

2016-09-08 Thread Marcos Dione

Changes by Marcos Dione :


--
versions: +Python 3.3, Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28019] itertools.count() falls back to fast (integer) mode when step rounds to 1

2016-09-08 Thread Marcos Dione

Marcos Dione added the comment:

Here's a first approach on fixing this bug. I'm not sure how to handle the case 
where step=1.0.

--
keywords: +patch
Added file: http://bugs.python.org/file44466/fix_28019.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28019] itertools.count() falls back to fast (integer) mode when step rounds to 1

2016-09-08 Thread Facundo Batista

Changes by Facundo Batista :


--
versions: +Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28019] itertools.count() falls back to fast (integer) mode when step rounds to 1

2016-09-08 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28019] itertools.count() falls back to fast (integer) mode when step rounds to 1

2016-09-08 Thread Marcos Dione

New submission from Marcos Dione:

If the `step` parameter for `itertools.count()` rounds to 1 (f.i., 1.1, 
1.437643, 1.9), 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

--
components: Library (Lib)
messages: 275007
nosy: StyXman
priority: normal
severity: normal
status: open
title: itertools.count() falls back to fast (integer) mode when step rounds to 1
type: behavior
versions: Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com