diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | class.c | 1 | ||||
-rw-r--r-- | ext/json/generator/generator.c | 1 | ||||
-rw-r--r-- | ext/zlib/zlib.c | 1 | ||||
-rw-r--r-- | test/ruby/test_hash.rb | 8 | ||||
-rw-r--r-- | test/ruby/test_module.rb | 11 | ||||
-rw-r--r-- | version.h | 6 |
7 files changed, 28 insertions, 5 deletions
@@ -1,3 +1,8 @@ +Sat Feb 22 09:26:05 2014 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * class.c (rb_mod_init_copy): do nothing if copying self. + [ruby-dev:47989] [Bug #9535] + Tue Feb 18 22:53:34 2014 NAKAMURA Usaku <usa@ruby-lang.org> * ruby_atomic.h: fixed merge mistake of r44946. reported by ngoto at @@ -180,6 +180,7 @@ rb_mod_init_copy(VALUE clone, VALUE orig) if (RB_TYPE_P(clone, T_CLASS)) { class_init_copy_check(clone, orig); } + if (clone == orig) return clone; rb_obj_init_copy(clone, orig); if (!FL_TEST(CLASS_OF(clone), FL_SINGLETON)) { RBASIC(clone)->klass = rb_singleton_class_clone(orig); diff --git a/ext/json/generator/generator.c b/ext/json/generator/generator.c index 0db7f2a73a..c5bbec08a4 100644 --- a/ext/json/generator/generator.c +++ b/ext/json/generator/generator.c @@ -1033,6 +1033,7 @@ static VALUE cState_init_copy(VALUE obj, VALUE orig) { JSON_Generator_State *objState, *origState; + if (obj == orig) return obj; Data_Get_Struct(obj, JSON_Generator_State, objState); Data_Get_Struct(orig, JSON_Generator_State, origState); if (!objState) rb_raise(rb_eArgError, "unallocated JSON::State"); diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 750074101e..b916910e3e 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -1334,6 +1334,7 @@ rb_deflate_init_copy(VALUE self, VALUE orig) Data_Get_Struct(self, struct zstream, z1); z2 = get_zstream(orig); + if (z1 == z2) return self; err = deflateCopy(&z1->stream, &z2->stream); if (err != Z_OK) { raise_zlib_error(err, 0); diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index af3fa78e0a..019196bd2e 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -117,6 +117,12 @@ class TestHash < Test::Unit::TestCase end + def test_self_initialize_copy + h = @cls[1=>2] + h.instance_eval {initialize_copy(h)} + assert_equal(2, h[1]) + end + def test_AREF # '[]' t = Time.now h = @cls[ @@ -145,8 +151,6 @@ class TestHash < Test::Unit::TestCase assert_equal('nil', h1[nil]) assert_equal(nil, h1['nil']) assert_equal(:default, h1['koala']) - - end def test_ASET # '[]=' diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index e72a6ab8c9..1fe67df2be 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -277,6 +277,17 @@ class TestModule < Test::Unit::TestCase assert_equal([:MIXIN, :USER], User.constants.sort) end + def test_self_initialize_copy + bug9535 = '[ruby-dev:47989] [Bug #9535]' + m = Module.new do + def foo + :ok + end + initialize_copy(self) + end + assert_equal(:ok, Object.new.extend(m).foo, bug9535) + end + def test_included_modules assert_equal([], Mixin.included_modules) assert_equal([Mixin], User.included_modules) @@ -1,10 +1,10 @@ #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 537 +#define RUBY_PATCHLEVEL 538 -#define RUBY_RELEASE_DATE "2014-02-19" +#define RUBY_RELEASE_DATE "2014-02-22" #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 -#define RUBY_RELEASE_DAY 19 +#define RUBY_RELEASE_DAY 22 #include "ruby/version.h" |