* class.c (rb_check_inheritable): preserve encoding in an error
  message when the superclass is not a class.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-06-28 03:28:50 +00:00
Родитель c70572d5a8
Коммит da70f4d02a
2 изменённых файлов: 5 добавлений и 2 удалений

Просмотреть файл

@ -214,8 +214,8 @@ void
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");

Просмотреть файл

@ -193,6 +193,9 @@ class TestClass < Test::Unit::TestCase
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