summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-22 00:50:33 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-22 00:50:33 +0000
commit9e11c028e3ff12da9e44f1ece7d100b84834e183 (patch)
treee4cb1f38eaef871e9132a97a9dc5ef96f71afe55
parent941bd1c392d9213193804ef9be503c5d039dda04 (diff)
merge revision(s) 45076: [Backport #9535]
* class.c (rb_mod_init_copy): do nothing if copying self. [ruby-dev:47989] [Bug #9535] * hash.c (rb_hash_initialize_copy): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@45091 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--class.c1
-rw-r--r--ext/json/generator/generator.c1
-rw-r--r--ext/zlib/zlib.c1
-rw-r--r--test/ruby/test_hash.rb8
-rw-r--r--test/ruby/test_module.rb11
-rw-r--r--version.h6
7 files changed, 28 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 91adf52249..1f699c3a35 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/class.c b/class.c
index 02e682688c..ca029895ea 100644
--- a/class.c
+++ b/class.c
@@ -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)
diff --git a/version.h b/version.h
index c686ebfc36..261aaad913 100644
--- a/version.h
+++ b/version.h
@@ -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"