ruby-changes:15605
From: mame <ko1@a...>
Date: Tue, 27 Apr 2010 22:42:45 +0900 (JST)
Subject: [ruby-changes:15605] Ruby:r27514 (trunk): * iseq.c (set_relation): do not use top_wrapper as bottom of cref,
mame 2010-04-27 22:42:29 +0900 (Tue, 27 Apr 2010) New Revision: 27514 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=27514 Log: * iseq.c (set_relation): do not use top_wrapper as bottom of cref, which caused constant lookup error when "wrapped load" is used; instead, use Object as bottom, and push top_wrapper on Object. [ruby-core:25039] Modified files: trunk/ChangeLog trunk/iseq.c trunk/test/ruby/test_require.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 27513) +++ ChangeLog (revision 27514) @@ -1,3 +1,10 @@ +Tue Apr 27 22:40:54 2010 Yusuke Endoh <mame@t...> + + * iseq.c (set_relation): do not use top_wrapper as bottom of cref, + which caused constant lookup error when "wrapped load" is used; + instead, use Object as bottom, and push top_wrapper on Object. + [ruby-core:25039] + Tue Apr 27 21:24:40 2010 Yusuke Endoh <mame@t...> * eval.c (ruby_cleanup): before cleanup, check signal buffer and run Index: iseq.c =================================================================== --- iseq.c (revision 27513) +++ iseq.c (revision 27514) @@ -177,9 +177,16 @@ /* set class nest stack */ if (type == ISEQ_TYPE_TOP) { /* toplevel is private */ - iseq->cref_stack = NEW_BLOCK(th->top_wrapper ? th->top_wrapper : rb_cObject); + iseq->cref_stack = NEW_BLOCK(rb_cObject); iseq->cref_stack->nd_file = 0; iseq->cref_stack->nd_visi = NOEX_PRIVATE; + if (th->top_wrapper) { + NODE *cref = NEW_BLOCK(th->top_wrapper); + cref->nd_file = 0; + cref->nd_visi = NOEX_PRIVATE; + cref->nd_next = iseq->cref_stack; + iseq->cref_stack = cref; + } } else if (type == ISEQ_TYPE_METHOD || type == ISEQ_TYPE_CLASS) { iseq->cref_stack = NEW_BLOCK(0); /* place holder */ Index: test/ruby/test_require.rb =================================================================== --- test/ruby/test_require.rb (revision 27513) +++ test/ruby/test_require.rb (revision 27514) @@ -197,6 +197,19 @@ assert_raise(ArgumentError) { at_exit } end + def test_load2 # [ruby-core:25039] + t = Tempfile.new(["test_ruby_test_require", ".rb"]) + t.puts "Hello = 'hello'" + t.puts "class Foo" + t.puts " p Hello" + t.puts "end" + t.close + + assert_in_out_err([], <<-INPUT, %w("hello"), []) + load(#{ t.path.dump }, true) + INPUT + end + def test_tainted_loadpath t = Tempfile.new(["test_ruby_test_require", ".rb"]) abs_dir, file = File.split(t.path) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/