mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
class.c: preserve encoding
* 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:
parent
c70572d5a8
commit
da70f4d02a
2 changed files with 5 additions and 2 deletions
4
class.c
4
class.c
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue