Visitar URL original
gh-101892: Fix SystemError when a callable iterator call exhausts the iterator by workingpayload · Pull Request #101896 · python/cpython · GitHub
Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix issues reported by patchcheck
  • Loading branch information
arhadthedev committed Feb 15, 2023
commit fe1502dab4d2c60a68d413138e0d4a55a42c8222
6 changes: 3 additions & 3 deletions Lib/test/test_iter.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __call__(self):

def exhaust(iterator):
Comment thread
arhadthedev marked this conversation as resolved.
Outdated
"""Exhaust an iterator without raising StopIteration."""
list(iterator)
list(iterator)


# Main test suite
Expand Down Expand Up @@ -273,7 +273,7 @@ def spam(state=[0]):
return i
self.check_iterator(iter(spam, 20), list(range(10)), pickle=False)

# Test two-argument iter() with function that exhausts its
# Test two-argument iter() with function that exhausts its
Comment thread
arhadthedev marked this conversation as resolved.
Outdated
# associated iterator but forgets to either return a sentinel value
# or raise `StopIteration`.
def test_iter_function_concealing_reentrant_exhaustion(self):
Expand All @@ -287,7 +287,7 @@ def spam():
spam.is_recursive_call = True
exhaust(spam.iterator)
return HAS_MORE

spam.is_recursive_call = False
spam.iterator = iter(spam, NO_MORE)
with self.assertRaises(StopIteration):
Expand Down