Skip to content

Commit

Permalink
(alex, arigo) fix a crash with raising an exception in a fiber
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Gaynor committed Mar 19, 2013
1 parent 8e12a0f commit eb0320b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/objects/test_fiberobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,11 @@ def test_nested_resume_yield(self, space):
f1.resume
f2.resume
""")

def test_multiple_resume_exception(self, space):
space.execute("""
$f = Fiber.new { Fiber.yield; raise "error" }
$f.resume
""")
with self.raises(space, "RuntimeError", "error"):
space.execute("$f.resume")
2 changes: 2 additions & 0 deletions topaz/objects/fiberobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def singleton_method_yield(self, space, args_w):
space.fromcache(State).current = parent_fiber

topframeref = space.getexecutioncontext().topframeref
current.bottomframe.backref = jit.vref_None
if len(args_w) == 0:
global_state.w_result = space.w_nil
elif len(args_w) == 1:
Expand All @@ -75,6 +76,7 @@ def singleton_method_yield(self, space, args_w):
global_state.w_result = space.newarray(args_w)
parent_fiber.h = space.getexecutioncontext().fiber_thread.switch(parent_fiber.h)
assert space.fromcache(State).current is current
current.bottomframe.backref = space.getexecutioncontext().topframeref
space.getexecutioncontext().topframeref = topframeref

return get_result()
Expand Down

0 comments on commit eb0320b

Please sign in to comment.