ruby-changes:42054
From: nobu <ko1@a...>
Date: Wed, 16 Mar 2016 20:03:43 +0900 (JST)
Subject: [ruby-changes:42054] nobu:r54128 (trunk): proc.c: fail symbol proc binding
nobu 2016-03-16 20:03:38 +0900 (Wed, 16 Mar 2016) New Revision: 54128 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54128 Log: proc.c: fail symbol proc binding * proc.c (proc_binding): proc from symbol can not make a binding. [ruby-core:74100] [Bug #12137] Modified files: trunk/ChangeLog trunk/proc.c trunk/test/ruby/test_symbol.rb Index: proc.c =================================================================== --- proc.c (revision 54127) +++ proc.c (revision 54128) @@ -2658,6 +2658,7 @@ proc_binding(VALUE self) https://github.com/ruby/ruby/blob/trunk/proc.c#L2658 GetProcPtr(self, proc); envval = rb_vm_proc_envval(proc); iseq = proc->block.iseq; + if (SYMBOL_P(iseq)) goto error; if (RUBY_VM_IFUNC_P(iseq)) { struct vm_ifunc *ifunc = (struct vm_ifunc *)iseq; if (IS_METHOD_PROC_IFUNC(ifunc)) { @@ -2666,6 +2667,7 @@ proc_binding(VALUE self) https://github.com/ruby/ruby/blob/trunk/proc.c#L2667 iseq = rb_method_iseq(method); } else { + error: rb_raise(rb_eArgError, "Can't create Binding from C level Proc"); } } Index: ChangeLog =================================================================== --- ChangeLog (revision 54127) +++ ChangeLog (revision 54128) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Mar 16 20:03:35 2016 Nobuyoshi Nakada <nobu@r...> + + * proc.c (proc_binding): proc from symbol can not make a binding. + [ruby-core:74100] [Bug #12137] + Wed Mar 16 18:42:45 2016 Martin Duerst <duerst@i...> * test/ruby/enc/test_case_mapping.rb: Fixed and activated a test for Cherokee. Index: test/ruby/test_symbol.rb =================================================================== --- test/ruby/test_symbol.rb (revision 54127) +++ test/ruby/test_symbol.rb (revision 54128) @@ -176,6 +176,15 @@ class TestSymbol < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_symbol.rb#L176 end; end + def test_to_proc_binding + assert_separately([], <<~"end;", timeout: 1) # do + bug12137 = '[ruby-core:74100] [Bug #12137]' + assert_raise(ArgumentError, bug12137) { + :succ.to_proc.binding + } + end; + end + def test_call o = Object.new def o.foo(x, y); x + y; end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/