Skip to content

Commit 9e11c02

Browse files
committed
merge revision(s) 45076: [Backport ruby#9535]
* class.c (rb_mod_init_copy): do nothing if copying self. [ruby-dev:47989] [Bug ruby#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
1 parent 941bd1c commit 9e11c02

File tree

7 files changed

+28
-5
lines changed

7 files changed

+28
-5
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Sat Feb 22 09:26:05 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
2+
3+
* class.c (rb_mod_init_copy): do nothing if copying self.
4+
[ruby-dev:47989] [Bug #9535]
5+
16
Tue Feb 18 22:53:34 2014 NAKAMURA Usaku <usa@ruby-lang.org>
27

38
* ruby_atomic.h: fixed merge mistake of r44946. reported by ngoto at

class.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
180180
if (RB_TYPE_P(clone, T_CLASS)) {
181181
class_init_copy_check(clone, orig);
182182
}
183+
if (clone == orig) return clone;
183184
rb_obj_init_copy(clone, orig);
184185
if (!FL_TEST(CLASS_OF(clone), FL_SINGLETON)) {
185186
RBASIC(clone)->klass = rb_singleton_class_clone(orig);

ext/json/generator/generator.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,7 @@ static VALUE cState_init_copy(VALUE obj, VALUE orig)
10331033
{
10341034
JSON_Generator_State *objState, *origState;
10351035

1036+
if (obj == orig) return obj;
10361037
Data_Get_Struct(obj, JSON_Generator_State, objState);
10371038
Data_Get_Struct(orig, JSON_Generator_State, origState);
10381039
if (!objState) rb_raise(rb_eArgError, "unallocated JSON::State");

ext/zlib/zlib.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,7 @@ rb_deflate_init_copy(VALUE self, VALUE orig)
13341334
Data_Get_Struct(self, struct zstream, z1);
13351335
z2 = get_zstream(orig);
13361336

1337+
if (z1 == z2) return self;
13371338
err = deflateCopy(&z1->stream, &z2->stream);
13381339
if (err != Z_OK) {
13391340
raise_zlib_error(err, 0);

test/ruby/test_hash.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ def test_s_new
117117

118118
end
119119

120+
def test_self_initialize_copy
121+
h = @cls[1=>2]
122+
h.instance_eval {initialize_copy(h)}
123+
assert_equal(2, h[1])
124+
end
125+
120126
def test_AREF # '[]'
121127
t = Time.now
122128
h = @cls[
@@ -145,8 +151,6 @@ def test_AREF # '[]'
145151
assert_equal('nil', h1[nil])
146152
assert_equal(nil, h1['nil'])
147153
assert_equal(:default, h1['koala'])
148-
149-
150154
end
151155

152156
def test_ASET # '[]='

test/ruby/test_module.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,17 @@ def test_constants
277277
assert_equal([:MIXIN, :USER], User.constants.sort)
278278
end
279279

280+
def test_self_initialize_copy
281+
bug9535 = '[ruby-dev:47989] [Bug #9535]'
282+
m = Module.new do
283+
def foo
284+
:ok
285+
end
286+
initialize_copy(self)
287+
end
288+
assert_equal(:ok, Object.new.extend(m).foo, bug9535)
289+
end
290+
280291
def test_included_modules
281292
assert_equal([], Mixin.included_modules)
282293
assert_equal([Mixin], User.included_modules)

version.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#define RUBY_VERSION "1.9.3"
2-
#define RUBY_PATCHLEVEL 537
2+
#define RUBY_PATCHLEVEL 538
33

4-
#define RUBY_RELEASE_DATE "2014-02-19"
4+
#define RUBY_RELEASE_DATE "2014-02-22"
55
#define RUBY_RELEASE_YEAR 2014
66
#define RUBY_RELEASE_MONTH 2
7-
#define RUBY_RELEASE_DAY 19
7+
#define RUBY_RELEASE_DAY 22
88

99
#include "ruby/version.h"
1010

0 commit comments

Comments
 (0)