Kaydet (Commit) 187e6480 authored tarafından Jack Diederich's avatar Jack Diederich

backport of r51950

* regression bug, count_next was coercing a Py_ssize_t to an unsigned Py_size_t
  which breaks negative counts
* added test for negative numbers
üst c70e003f
......@@ -58,6 +58,10 @@ class TestBasicOps(unittest.TestCase):
self.assertEqual(repr(c), 'count(3)')
c.next()
self.assertEqual(repr(c), 'count(4)')
c = count(-9)
self.assertEqual(repr(c), 'count(-9)')
c.next()
self.assertEqual(c.next(), -8)
def test_cycle(self):
self.assertEqual(take(10, cycle('abc')), list('abcabcabca'))
......
......@@ -2072,7 +2072,7 @@ count_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject *
count_next(countobject *lz)
{
return PyInt_FromSize_t(lz->cnt++);
return PyInt_FromSsize_t(lz->cnt++);
}
static PyObject *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment