object.c: no TypeError at special const dup
* object.c (rb_obj_dup): no longer raise a TypeError for special constants, and return itself instead. [Feature#12979] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
673a6ad970
commit
70d8e6cf22
2
object.c
2
object.c
@ -423,7 +423,7 @@ rb_obj_dup(VALUE obj)
|
|||||||
VALUE dup;
|
VALUE dup;
|
||||||
|
|
||||||
if (rb_special_const_p(obj)) {
|
if (rb_special_const_p(obj)) {
|
||||||
rb_raise(rb_eTypeError, "can't dup %s", rb_obj_classname(obj));
|
return obj;
|
||||||
}
|
}
|
||||||
dup = rb_obj_alloc(rb_obj_class(obj));
|
dup = rb_obj_alloc(rb_obj_class(obj));
|
||||||
init_copy(dup, obj);
|
init_copy(dup, obj);
|
||||||
|
@ -19,9 +19,9 @@ class TestObject < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_dup
|
def test_dup
|
||||||
assert_raise(TypeError) { 1.dup }
|
assert_equal 1, 1.dup
|
||||||
assert_raise(TypeError) { true.dup }
|
assert_equal true, true.dup
|
||||||
assert_raise(TypeError) { nil.dup }
|
assert_equal nil, nil.dup
|
||||||
|
|
||||||
assert_raise(TypeError) do
|
assert_raise(TypeError) do
|
||||||
Object.new.instance_eval { initialize_copy(1) }
|
Object.new.instance_eval { initialize_copy(1) }
|
||||||
|
@ -1260,7 +1260,7 @@ dependencies: []
|
|||||||
s.version = '1'
|
s.version = '1'
|
||||||
end
|
end
|
||||||
|
|
||||||
spec.instance_variable_set :@licenses, :blah
|
spec.instance_variable_set :@licenses, Object.new.singleton_class
|
||||||
spec.loaded_from = '/path/to/file'
|
spec.loaded_from = '/path/to/file'
|
||||||
|
|
||||||
e = assert_raises Gem::FormatException do
|
e = assert_raises Gem::FormatException do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user