Skip to content

Commit

Permalink
line endings
Browse files Browse the repository at this point in the history
  • Loading branch information
hmaarrfk committed Jan 13, 2021
1 parent a04cbc3 commit ee5ce95
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions recipe/149-uninitialized_tuple.patch
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
diff --git a/cytoolz/itertoolz.pyx b/cytoolz/itertoolz.pyx
index e138f71..6c5bc88 100644
--- a/cytoolz/itertoolz.pyx
+++ b/cytoolz/itertoolz.pyx
@@ -960,12 +960,13 @@ cdef class sliding_window:
[1.5, 2.5, 3.5]
"""
def __cinit__(self, Py_ssize_t n, object seq):
cdef Py_ssize_t i
self.iterseq = iter(seq)
self.prev = PyTuple_New(n)
+ PyTuple_SET_ITEM(self.prev, 0, None)
for i, seq in enumerate(islice(self.iterseq, n-1), 1):
Py_INCREF(seq)
PyTuple_SET_ITEM(self.prev, i, seq)
self.n = n

def __iter__(self):
@@ -1051,12 +1052,14 @@ cdef class partition_all:
i += 1
if i == self.n:
return result
# iterable exhausted before filling the tuple
if i == 0:
raise StopIteration
+ for j in range(i, self.n):
+ PyTuple_SET_ITEM(result, j, None)
return PyTuple_GetSlice(result, 0, i)


cpdef object count(object seq):
"""
Count the number of items in seq
diff --git a/cytoolz/itertoolz.pyx b/cytoolz/itertoolz.pyx
index e138f71..6c5bc88 100644
--- a/cytoolz/itertoolz.pyx
+++ b/cytoolz/itertoolz.pyx
@@ -960,12 +960,13 @@ cdef class sliding_window:
[1.5, 2.5, 3.5]
"""
def __cinit__(self, Py_ssize_t n, object seq):
cdef Py_ssize_t i
self.iterseq = iter(seq)
self.prev = PyTuple_New(n)
+ PyTuple_SET_ITEM(self.prev, 0, None)
for i, seq in enumerate(islice(self.iterseq, n-1), 1):
Py_INCREF(seq)
PyTuple_SET_ITEM(self.prev, i, seq)
self.n = n

def __iter__(self):
@@ -1051,12 +1052,14 @@ cdef class partition_all:
i += 1
if i == self.n:
return result
# iterable exhausted before filling the tuple
if i == 0:
raise StopIteration
+ for j in range(i, self.n):
+ PyTuple_SET_ITEM(result, j, None)
return PyTuple_GetSlice(result, 0, i)


cpdef object count(object seq):
"""
Count the number of items in seq

0 comments on commit ee5ce95

Please sign in to comment.