ruby-changes:27514
From: nagachika <ko1@a...>
Date: Sun, 3 Mar 2013 02:24:41 +0900 (JST)
Subject: [ruby-changes:27514] nagachika:r39566 (ruby_2_0_0): merge revision(s) 39236: [Backport #7841]
nagachika 2013-03-03 02:24:30 +0900 (Sun, 03 Mar 2013) New Revision: 39566 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39566 Log: merge revision(s) 39236: [Backport #7841] * class.c (include_modules_at): detect cyclic prepend with original method table. [ruby-core:52205] [Bug #7841] 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 39565) +++ ruby_2_0_0/ChangeLog (revision 39566) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1 +Sun Mar 3 02:22:56 2013 Nobuyoshi Nakada <nobu@r...> + + * class.c (include_modules_at): detect cyclic prepend with original + method table. [ruby-core:52205] [Bug #7841] + Sun Mar 3 02:16:24 2013 Nobuyoshi Nakada <nobu@r...> * vm_method.c: call method_removed hook on called class, not on Index: ruby_2_0_0/class.c =================================================================== --- ruby_2_0_0/class.c (revision 39565) +++ ruby_2_0_0/class.c (revision 39566) @@ -681,7 +681,7 @@ rb_include_class_new(VALUE module, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/class.c#L681 return (VALUE)klass; } -static int include_modules_at(VALUE klass, VALUE c, VALUE module); +static int include_modules_at(const VALUE klass, VALUE c, VALUE module); void rb_include_module(VALUE klass, VALUE module) @@ -713,17 +713,18 @@ add_refined_method_entry_i(st_data_t key https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/class.c#L713 } static int -include_modules_at(VALUE klass, VALUE c, VALUE module) +include_modules_at(const VALUE klass, VALUE c, VALUE module) { VALUE p; int changed = 0; + const st_table *const klass_m_tbl = RCLASS_M_TBL(RCLASS_ORIGIN(klass)); while (module) { int superclass_seen = FALSE; if (RCLASS_ORIGIN(module) != module) goto skip; - if (RCLASS_M_TBL(klass) && RCLASS_M_TBL(klass) == RCLASS_M_TBL(module)) + if (klass_m_tbl && klass_m_tbl == RCLASS_M_TBL(module)) return -1; /* ignore if the module included already in superclasses */ for (p = RCLASS_SUPER(klass); p; p = RCLASS_SUPER(p)) { Index: ruby_2_0_0/version.h =================================================================== --- ruby_2_0_0/version.h (revision 39565) +++ ruby_2_0_0/version.h (revision 39566) @@ -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 "2013-03-03" -#define RUBY_PATCHLEVEL 5 +#define RUBY_PATCHLEVEL 6 #define RUBY_RELEASE_YEAR 2013 #define RUBY_RELEASE_MONTH 3 Index: ruby_2_0_0/test/ruby/test_module.rb =================================================================== --- ruby_2_0_0/test/ruby/test_module.rb (revision 39565) +++ ruby_2_0_0/test/ruby/test_module.rb (revision 39566) @@ -1465,6 +1465,16 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_module.rb#L1465 assert_equal([:m1], Class.new(Class.new{def m2;end}){ prepend Module.new; def m1; end }.instance_methods(false), bug6660) end + def test_cyclic_prepend + bug7841 = '[ruby-core:52205] [Bug #7841]' + m1 = Module.new + m2 = Module.new + m1.instance_eval { prepend(m2) } + assert_raise(ArgumentError, bug7841) do + m2.instance_eval { prepend(m1) } + end + end + def test_class_variables m = Module.new m.class_variable_set(:@@foo, 1) Property changes on: ruby_2_0_0 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r39236 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/