ruby-changes:25218
From: nobu <ko1@a...>
Date: Fri, 19 Oct 2012 22:24:24 +0900 (JST)
Subject: [ruby-changes:25218] nobu:r37270 (trunk): vm.c: pass through thrown objects
nobu 2012-10-19 22:22:03 +0900 (Fri, 19 Oct 2012) New Revision: 37270 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37270 Log: vm.c: pass through thrown objects * vm.c (rb_vm_jump_tag_but_local_jump): pass through thrown objects. [ruby-dev:46234] [Bug #7185] * vm_eval.c (rb_eval_cmd): if state is non-zero, val should be nil and rb_vm_jump_tag_but_local_jump() just jump tag. Modified files: trunk/ChangeLog trunk/test/ruby/test_exception.rb trunk/vm.c trunk/vm_eval.c Index: ChangeLog =================================================================== --- ChangeLog (revision 37269) +++ ChangeLog (revision 37270) @@ -1,3 +1,11 @@ +Fri Oct 19 22:22:01 2012 Nobuyoshi Nakada <nobu@r...> + + * vm.c (rb_vm_jump_tag_but_local_jump): pass through thrown objects. + [ruby-dev:46234] [Bug #7185] + + * vm_eval.c (rb_eval_cmd): if state is non-zero, val should be nil and + rb_vm_jump_tag_but_local_jump() just jump tag. + Fri Oct 19 22:11:55 2012 Benoit Daloze <eregontp@g...> * pack.c (pack_unpack): set encoding of the Index: vm_eval.c =================================================================== --- vm_eval.c (revision 37269) +++ vm_eval.c (revision 37270) @@ -1335,7 +1335,7 @@ POP_TAG(); rb_set_safe_level_force(safe); - if (state) rb_vm_jump_tag_but_local_jump(state, val); + if (state) JUMP_TAG(state); return val; } Index: vm.c =================================================================== --- vm.c (revision 37269) +++ vm.c (revision 37270) @@ -916,7 +916,7 @@ { if (val != Qnil) { VALUE exc = rb_vm_make_jump_tag_but_local_jump(state, val); - rb_exc_raise(exc); + if (!NIL_P(exc)) rb_exc_raise(exc); } JUMP_TAG(state); } Index: test/ruby/test_exception.rb =================================================================== --- test/ruby/test_exception.rb (revision 37269) +++ test/ruby/test_exception.rb (revision 37270) @@ -104,7 +104,16 @@ end false }) + end + def test_catch_throw_in_require + bug7185 = '[ruby-dev:46234]' + t = Tempfile.open(["dep", ".rb"]) + t.puts("throw :extdep, 42") + t.close + assert_equal(42, catch(:extdep) {require t.path}, bug7185) + ensure + t.close! if t end def test_else_no_exception -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/