ruby-changes:38969
From: nobu <ko1@a...>
Date: Sun, 28 Jun 2015 12:29:07 +0900 (JST)
Subject: [ruby-changes:38969] nobu:r51050 (trunk): class.c: preserve encoding
nobu 2015-06-28 12:28:50 +0900 (Sun, 28 Jun 2015) New Revision: 51050 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51050 Log: class.c: preserve encoding * class.c (rb_check_inheritable): preserve encoding in an error message when the superclass is not a class. Modified files: trunk/class.c trunk/test/ruby/test_class.rb Index: class.c =================================================================== --- class.c (revision 51049) +++ class.c (revision 51050) @@ -214,8 +214,8 @@ void https://github.com/ruby/ruby/blob/trunk/class.c#L214 rb_check_inheritable(VALUE super) { if (!RB_TYPE_P(super, T_CLASS)) { - rb_raise(rb_eTypeError, "superclass must be a Class (%s given)", - rb_obj_classname(super)); + rb_raise(rb_eTypeError, "superclass must be a Class (%"PRIsVALUE" given)", + rb_obj_class(super)); } if (RBASIC(super)->flags & FL_SINGLETON) { rb_raise(rb_eTypeError, "can't make subclass of singleton class"); Index: test/ruby/test_class.rb =================================================================== --- test/ruby/test_class.rb (revision 51049) +++ test/ruby/test_class.rb (revision 51050) @@ -193,6 +193,9 @@ class TestClass < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_class.rb#L193 assert_raise(TypeError) { Class.new(c) } assert_raise(TypeError) { Class.new(Class) } assert_raise(TypeError) { eval("class Foo < Class; end") } + m = "M\u{1f5ff}" + o = Class.new {break eval("class #{m}; self; end.new")} + assert_raise_with_message(TypeError, /#{m}/) {Class.new(o)} end def test_initialize_copy -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/