ruby-changes:30182
From: knu <ko1@a...>
Date: Mon, 29 Jul 2013 21:06:58 +0900 (JST)
Subject: [ruby-changes:30182] knu:r42234 (trunk): Add a frozenness check to Enumerator::Generator#initialize.
knu 2013-07-29 21:06:42 +0900 (Mon, 29 Jul 2013) New Revision: 42234 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42234 Log: Add a frozenness check to Enumerator::Generator#initialize. * enumerator.c (generator_init): Ditto. Modified files: trunk/enumerator.c trunk/test/ruby/test_enumerator.rb Index: enumerator.c =================================================================== --- enumerator.c (revision 42233) +++ enumerator.c (revision 42234) @@ -1178,6 +1178,7 @@ generator_init(VALUE obj, VALUE proc) https://github.com/ruby/ruby/blob/trunk/enumerator.c#L1178 { struct generator *ptr; + rb_check_frozen(obj); TypedData_Get_Struct(obj, struct generator, &generator_data_type, ptr); if (!ptr) { Index: test/ruby/test_enumerator.rb =================================================================== --- test/ruby/test_enumerator.rb (revision 42233) +++ test/ruby/test_enumerator.rb (revision 42234) @@ -419,6 +419,11 @@ class TestEnumerator < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/ruby/test_enumerator.rb#L419 a = [] assert_equal(:foo, g2.each {|x| a << x }) assert_equal([1, 2, 3], a) + + g.freeze + assert_raise(RuntimeError) { + g.__send__ :initialize, proc { |y| y << 4 << 5 } + } end def test_generator_args -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/