From bcf67b862b44ea3b0ddb453895983915f80981fe Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 23 Dec 2009 06:22:48 +0000 Subject: * iseq.c (iseq_s_disasm): return nil for native methods. [ruby-core:27226], [Bug#2499] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@26158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- eval_intern.h | 1 - include/ruby/intern.h | 1 + iseq.c | 2 +- test/ruby/test_method.rb | 1 + 4 files changed, 3 insertions(+), 2 deletions(-) diff --git a/eval_intern.h b/eval_intern.h index b7790828d..549953acf 100644 --- a/eval_intern.h +++ b/eval_intern.h @@ -205,7 +205,6 @@ NORETURN(void rb_raise_method_missing(rb_thread_t *th, int argc, VALUE *argv, VALUE rb_vm_make_jump_tag_but_local_jump(int state, VALUE val); NODE *rb_vm_cref(void); -VALUE rb_obj_is_proc(VALUE); VALUE rb_vm_call_cfunc(VALUE recv, VALUE (*func)(VALUE), VALUE arg, const rb_block_t *blockptr, VALUE filename); void rb_vm_set_progname(VALUE filename); void rb_thread_terminate_all(void); diff --git a/include/ruby/intern.h b/include/ruby/intern.h index 91551079d..14e23b857 100644 --- a/include/ruby/intern.h +++ b/include/ruby/intern.h @@ -303,6 +303,7 @@ VALUE rb_class_new_instance(int, VALUE*, VALUE); VALUE rb_block_proc(void); VALUE rb_f_lambda(void); VALUE rb_proc_new(VALUE (*)(ANYARGS/* VALUE yieldarg[, VALUE procarg] */), VALUE); +VALUE rb_obj_is_proc(VALUE); VALUE rb_proc_call(VALUE, VALUE); VALUE rb_proc_call_with_block(VALUE, int argc, VALUE *argv, VALUE); int rb_proc_arity(VALUE); diff --git a/iseq.c b/iseq.c index 1f00132c7..7a59fce04 100644 --- a/iseq.c +++ b/iseq.c @@ -1015,7 +1015,7 @@ iseq_s_disasm(VALUE klass, VALUE body) if ((iseq = rb_method_get_iseq(body)) != 0) { ret = rb_iseq_disasm(iseq->self); } - else { + else if (rb_obj_is_proc(body)) { rb_proc_t *proc; VALUE iseqval; GetProcPtr(body, proc); diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb index c60f7fa8a..d5d6a0e68 100644 --- a/test/ruby/test_method.rb +++ b/test/ruby/test_method.rb @@ -82,6 +82,7 @@ class TestMethod < Test::Unit::TestCase o = Object.new def o.foo; end assert_nothing_raised { RubyVM::InstructionSequence.disasm(o.method(:foo)) } + assert_nothing_raised { RubyVM::InstructionSequence.disasm("x".method(:upcase)) } end def test_new -- cgit