ruby-changes:33403
From: nobu <ko1@a...>
Date: Mon, 31 Mar 2014 11:34:47 +0900 (JST)
Subject: [ruby-changes:33403] nobu:r45482 (trunk): vm.c: avoid inadvertent pin-down
nobu 2014-03-31 11:34:40 +0900 (Mon, 31 Mar 2014) New Revision: 45482 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45482 Log: vm.c: avoid inadvertent pin-down * vm.c (vm_stat): get rid of inadvertent dynamic symbol pin-down, and preserve encoding in error messages. also should not use RSTRING_PTR macro on function calls. Modified files: trunk/test/ruby/test_rubyvm.rb trunk/vm.c Index: vm.c =================================================================== --- vm.c (revision 45481) +++ vm.c (revision 45482) @@ -173,8 +173,9 @@ vm_stat(int argc, VALUE *argv, VALUE sel https://github.com/ruby/ruby/blob/trunk/vm.c#L173 SET(class_serial, ruby_vm_class_serial); #undef SET - if (key != Qnil) /* matched key should return above */ - rb_raise(rb_eArgError, "unknown key: %s", RSTRING_PTR(rb_id2str(SYM2ID(key)))); + if (!NIL_P(key)) { /* matched key should return above */ + rb_raise(rb_eArgError, "unknown key: %"PRIsVALUE, rb_sym2str(key)); + } return hash; } Index: test/ruby/test_rubyvm.rb =================================================================== --- test/ruby/test_rubyvm.rb (revision 45481) +++ test/ruby/test_rubyvm.rb (revision 45482) @@ -12,5 +12,6 @@ class TestRubyVM < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyvm.rb#L12 def test_stat_unknown assert_raise(ArgumentError){ RubyVM.stat(:unknown) } + assert_raise_with_message(ArgumentError, /\u{30eb 30d3 30fc}/) {RubyVM.stat(:"\u{30eb 30d3 30fc}")} end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/