Skip to content

Fix remaining test_contextlib tests - #2156

Merged
slozier merged 1 commit into
IronLanguages:mainfrom
slozier:test_contextlib
Nov 8, 2026
Merged

slozier merged 1 commit into
IronLanguages:mainfrom
slozier:test_contextlib

Conversation

@slozier

@slozier slozier commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Fix remaining test_contextlib tests.

throw() raised StopIteration('') whenever the generator finished, so:

  • a return value was lost
  • a StopIteration raised in the body wasn't propagated as-is (and so wasn't turned into RuntimeError by generator_stop).

For example (these are covered by the test_contextlib and test_yield_from):

def g():
    try: yield 1
    except ValueError: return 5

gi = g()
next(gi)
try:
    gi.throw(ValueError)
except StopIteration as e:
    assert e.value == 5
def g():
    yield

stop = StopIteration()
gi = g()
next(gi)
try:
    gi.throw(stop)
except StopIteration as e:
    assert e is stop

Part of #1

@slozier
slozier merged commit 199aa7a into IronLanguages:main Nov 8, 2026
34 of 35 checks passed
@slozier
slozier deleted the test_contextlib branch November 8, 2026 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant