зеркало из https://github.com/github/ruby.git
object.c: message encoding
* object.c (rb_obj_clone2): preserve encoding in error messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57679 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
f5faaf7b9a
Коммит
f2c5146dc4
7
object.c
7
object.c
|
@ -354,14 +354,15 @@ rb_obj_clone2(int argc, VALUE *argv, VALUE obj)
|
|||
rb_get_kwargs(opt, keyword_ids, 0, 1, kwargs);
|
||||
kwfreeze = kwargs[0];
|
||||
if (kwfreeze != Qundef && kwfreeze != Qtrue && kwfreeze != Qfalse) {
|
||||
rb_raise(rb_eArgError, "unexpected value for freeze: %s",
|
||||
rb_builtin_class_name(kwfreeze));
|
||||
rb_raise(rb_eArgError, "unexpected value for freeze: %"PRIsVALUE,
|
||||
rb_obj_class(kwfreeze));
|
||||
}
|
||||
}
|
||||
|
||||
if (special_object_p(obj)) {
|
||||
if (kwfreeze == Qfalse)
|
||||
rb_raise(rb_eArgError, "can't unfreeze %s", rb_obj_classname(obj));
|
||||
rb_raise(rb_eArgError, "can't unfreeze %"PRIsVALUE,
|
||||
rb_obj_class(obj));
|
||||
return obj;
|
||||
}
|
||||
clone = rb_obj_alloc(rb_obj_class(obj));
|
||||
|
|
|
@ -61,6 +61,10 @@ class TestObject < Test::Unit::TestCase
|
|||
assert_raise(ArgumentError) {true.clone(freeze: false)}
|
||||
assert_raise(ArgumentError) {nil.clone(freeze: false)}
|
||||
assert_raise(ArgumentError) {false.clone(freeze: false)}
|
||||
x = EnvUtil.labeled_class("\u{1f4a9}").new
|
||||
assert_raise_with_message(ArgumentError, /\u{1f4a9}/) do
|
||||
Object.new.clone(freeze: x)
|
||||
end
|
||||
end
|
||||
|
||||
def test_init_dupclone
|
||||
|
|
Загрузка…
Ссылка в новой задаче