ruby-changes:34438
From: usa <ko1@a...>
Date: Mon, 23 Jun 2014 18:58:54 +0900 (JST)
Subject: [ruby-changes:34438] usa:r46519 (ruby_2_0_0): merge revision(s) 45874: [Backport #9813]
usa 2014-06-23 18:58:45 +0900 (Mon, 23 Jun 2014) New Revision: 46519 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46519 Log: merge revision(s) 45874: [Backport #9813] * class.c (rb_mod_init_copy): always clear instance variable, constant and method tables first, regardless the source tables. [ruby-dev:48182] [Bug #9813] Modified directories: branches/ruby_2_0_0/ Modified files: branches/ruby_2_0_0/ChangeLog branches/ruby_2_0_0/class.c branches/ruby_2_0_0/test/ruby/test_module.rb branches/ruby_2_0_0/version.h Index: ruby_2_0_0/ChangeLog =================================================================== --- ruby_2_0_0/ChangeLog (revision 46518) +++ ruby_2_0_0/ChangeLog (revision 46519) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1 +Mon Jun 23 18:51:43 2014 Nobuyoshi Nakada <nobu@r...> + + * class.c (rb_mod_init_copy): always clear instance variable, + constant and method tables first, regardless the source tables. + [ruby-dev:48182] [Bug #9813] + Mon Jun 23 18:50:13 2014 Nobuyoshi Nakada <nobu@r...> * thread.c (thread_start_func_2): stop if forked in a sub-thread, Index: ruby_2_0_0/class.c =================================================================== --- ruby_2_0_0/class.c (revision 46518) +++ ruby_2_0_0/class.c (revision 46519) @@ -205,12 +205,21 @@ rb_mod_init_copy(VALUE clone, VALUE orig https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/class.c#L205 } RCLASS_SUPER(clone) = RCLASS_SUPER(orig); RCLASS_EXT(clone)->allocator = RCLASS_EXT(orig)->allocator; + if (RCLASS_IV_TBL(clone)) { + st_free_table(RCLASS_IV_TBL(clone)); + RCLASS_IV_TBL(clone) = 0; + } + if (RCLASS_CONST_TBL(clone)) { + rb_free_const_table(RCLASS_CONST_TBL(clone)); + RCLASS_CONST_TBL(clone) = 0; + } + if (RCLASS_M_TBL(clone)) { + rb_free_m_table(RCLASS_M_TBL(clone)); + RCLASS_M_TBL(clone) = 0; + } if (RCLASS_IV_TBL(orig)) { st_data_t id; - if (RCLASS_IV_TBL(clone)) { - st_free_table(RCLASS_IV_TBL(clone)); - } RCLASS_IV_TBL(clone) = st_copy(RCLASS_IV_TBL(orig)); CONST_ID(id, "__tmp_classpath__"); st_delete(RCLASS_IV_TBL(clone), &id, 0); @@ -220,16 +229,11 @@ rb_mod_init_copy(VALUE clone, VALUE orig https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/class.c#L229 st_delete(RCLASS_IV_TBL(clone), &id, 0); } if (RCLASS_CONST_TBL(orig)) { - if (RCLASS_CONST_TBL(clone)) { - rb_free_const_table(RCLASS_CONST_TBL(clone)); - } + RCLASS_CONST_TBL(clone) = st_init_numtable(); st_foreach(RCLASS_CONST_TBL(orig), clone_const_i, (st_data_t)RCLASS_CONST_TBL(clone)); } if (RCLASS_M_TBL(orig)) { - if (RCLASS_M_TBL(clone)) { - rb_free_m_table(RCLASS_M_TBL(clone)); - } RCLASS_M_TBL(clone) = st_init_numtable(); st_foreach(RCLASS_M_TBL(orig), clone_method_i, (st_data_t)clone); } Index: ruby_2_0_0/version.h =================================================================== --- ruby_2_0_0/version.h (revision 46518) +++ ruby_2_0_0/version.h (revision 46519) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1 #define RUBY_VERSION "2.0.0" #define RUBY_RELEASE_DATE "2014-06-23" -#define RUBY_PATCHLEVEL 498 +#define RUBY_PATCHLEVEL 499 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 6 Index: ruby_2_0_0/test/ruby/test_module.rb =================================================================== --- ruby_2_0_0/test/ruby/test_module.rb (revision 46518) +++ ruby_2_0_0/test/ruby/test_module.rb (revision 46519) @@ -320,6 +320,25 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_module.rb#L320 assert_equal(:ok, Object.new.extend(m).foo, bug9535) end + def test_initialize_copy_empty + bug9813 = '[ruby-dev:48182] [Bug #9813]' + m = Module.new do + def x + end + const_set(:X, 1) + @x = 2 + end + assert_equal([:x], m.instance_methods) + assert_equal([:@x], m.instance_variables) + assert_equal([:X], m.constants) + m.module_eval do + initialize_copy(Module.new) + end + assert_empty(m.instance_methods, bug9813) + assert_empty(m.instance_variables, bug9813) + assert_empty(m.constants, bug9813) + end + def test_dup bug6454 = '[ruby-core:45132]' Property changes on: ruby_2_0_0 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r45874 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/