diff -r ddc95a9bc2e0 Lib/test/test_itertools.py --- a/Lib/test/test_itertools.py Wed Sep 07 13:18:40 2016 +0200 +++ b/Lib/test/test_itertools.py Thu Sep 08 17:06:48 2016 +0200 @@ -558,6 +558,7 @@ [Decimal('1.1'), Decimal('1.2'), Decimal('1.3')]) self.assertEqual(take(3, count(Fraction(2,3), Fraction(1,7))), [Fraction(2,3), Fraction(17,21), Fraction(20,21)]) + self.assertEqual(take(3, count(1, 1.5)), [1, 2.5, 4.0]) self.assertEqual(repr(take(3, count(10, 2.5))), repr([10, 12.5, 15.0])) c = count(3, 5) self.assertEqual(repr(c), 'count(3, 5)') diff -r ddc95a9bc2e0 Modules/itertoolsmodule.c --- a/Modules/itertoolsmodule.c Wed Sep 07 13:18:40 2016 +0200 +++ b/Modules/itertoolsmodule.c Thu Sep 08 17:06:48 2016 +0200 @@ -3911,7 +3911,7 @@ Py_ssize_t cnt = 0; PyObject *long_cnt = NULL; PyObject *long_step = NULL; - long step; + double step; static char *kwlist[] = {"start", "step", 0}; if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO:count", @@ -3949,8 +3949,8 @@ assert(long_cnt != NULL && long_step != NULL); /* Fast mode only works when the step is 1 */ - step = PyLong_AsLong(long_step); - if (step != 1) { + step = PyFloat_AsDouble(long_step); + if (step != 1.0) { slow_mode = 1; if (step == -1 && PyErr_Occurred()) PyErr_Clear();