ruby-changes:12286
From: nobu <ko1@a...>
Date: Tue, 7 Jul 2009 13:34:50 +0900 (JST)
Subject: [ruby-changes:12286] Ruby:r23979 (trunk): * enum.c (rb_enum_join): non-nil separator must be convertible to
nobu 2009-07-07 13:34:34 +0900 (Tue, 07 Jul 2009) New Revision: 23979 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23979 Log: * enum.c (rb_enum_join): non-nil separator must be convertible to String. [ruby-core:24172] Modified files: trunk/ChangeLog trunk/enum.c trunk/test/ruby/test_enum.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 23978) +++ ChangeLog (revision 23979) @@ -1,3 +1,8 @@ +Tue Jul 7 13:34:30 2009 Nobuyoshi Nakada <nobu@r...> + + * enum.c (rb_enum_join): non-nil separator must be convertible to + String. [ruby-core:24172] + Tue Jul 7 12:47:28 2009 Yukihiro Matsumoto <matz@r...> * enum.c (rb_enum_join): should propagate taint to the return Index: enum.c =================================================================== --- enum.c (revision 23978) +++ enum.c (revision 23979) @@ -1828,6 +1828,7 @@ args[0] = 0; args[1] = sep; + if (!NIL_P(sep)) StringValue(args[1]); rb_block_call(obj, id_each, 0, 0, join_i, (VALUE)args); if (!args[0]) args[0] = rb_str_new(0, 0); OBJ_INFECT(args[0], obj); Index: test/ruby/test_enum.rb =================================================================== --- test/ruby/test_enum.rb (revision 23978) +++ test/ruby/test_enum.rb (revision 23979) @@ -285,8 +285,15 @@ end def test_join + ofs = $, assert_equal("abc", ("a".."c").join("")) assert_equal("a-b-c", ("a".."c").join("-")) + $, = "-" + assert_equal("a-b-c", ("a".."c").join()) + $, = nil + assert_equal("abc", ("a".."c").join()) + assert_equal("123", (1..3).join()) + assert_raise(TypeError, '[ruby-core:24172]') {("a".."c").join(1)} class << (e = Object.new.extend(Enumerable)) def to_s "e" @@ -296,5 +303,7 @@ end end assert_equal("e", e.join("")) + ensure + $, = ofs end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/