8000 gh-134119: Fix crash from calling next() on exhausted template iterator by JelleZijlstra · Pull Request #134120 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-134119: Fix crash from calling next() on exhausted template iterator #134120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 17, 2025
Merged
Show file tree
Hide file tree
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
Apply suggestions from code review
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
  • Loading branch information
JelleZijlstra and picnixz authored May 17, 2025
commit c6d78ee7fcfe726b8e4cbc315cd979458a8f6c77
8 changes: 3 additions & 5 deletions Lib/test/test_string/test_templatelib.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,11 @@ def test_iter(self):
self.assertEqual(res[2], ' yz')

def test_exhausted(self):
# gh-134119
# See https://github.com/python/cpython/issues/134119.
template_iter = iter(t"{1}")
self.assertIsInstance(next(template_iter), Interpolation)
with self.assertRaises(StopIteration):
next(template_iter)
with self.assertRaises(StopIteration):
next(template_iter)
self.assertRaises(StopIteration, next, template_iter)
self.assertRaises(StopIteration, next, template_iter)


if __name__ == '__main__':
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Fix crash when calling ``next()`` on an exhausted template string iterator.
Fix crash when calling :func:`next` on an exhausted template string iterator.
Patch by Jelle Zijlstra.
Loading
0