ruby-changes:23168
From: nobu <ko1@a...>
Date: Tue, 3 Apr 2012 10:18:43 +0900 (JST)
Subject: [ruby-changes:23168] nobu:r35218 (trunk): * enumerator.c (inspect_enumerator): suppress uninitialized
nobu 2012-04-03 10:18:31 +0900 (Tue, 03 Apr 2012) New Revision: 35218 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35218 Log: * enumerator.c (inspect_enumerator): suppress uninitialized instance variable warnings. [ruby-dev:45449][Bug #6214] patched by no6v (Nobuhiro IMAI). Modified files: trunk/ChangeLog trunk/enumerator.c trunk/test/ruby/test_enumerator.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 35217) +++ ChangeLog (revision 35218) @@ -1,3 +1,9 @@ +Tue Apr 3 10:18:27 2012 Nobuyoshi Nakada <nobu@r...> + + * enumerator.c (inspect_enumerator): suppress uninitialized + instance variable warnings. [ruby-dev:45449][Bug #6214] + patched by no6v (Nobuhiro IMAI). + Mon Apr 2 13:25:08 2012 Nobuyoshi Nakada <nobu@r...> * lib/optparse/ac.rb: autoconf-like options. Index: enumerator.c =================================================================== --- enumerator.c (revision 35217) +++ enumerator.c (revision 35218) @@ -875,7 +875,7 @@ return str; } - eobj = rb_iv_get(obj, "receiver"); + eobj = rb_attr_get(obj, rb_intern("receiver")); if (NIL_P(eobj)) { eobj = e->obj; } @@ -886,7 +886,7 @@ /* (1..100).each_cons(2) => "#<Enumerator: 1..100:each_cons(2)>" */ str = rb_sprintf("#<%s: ", cname); rb_str_concat(str, rb_inspect(eobj)); - method = rb_iv_get(obj, "method"); + method = rb_attr_get(obj, rb_intern("method")); if (NIL_P(method)) { rb_str_buf_cat2(str, ":"); rb_str_buf_cat2(str, rb_id2name(e->meth)); @@ -897,7 +897,7 @@ rb_str_buf_cat2(str, rb_id2name(SYM2ID(method))); } - eargs = rb_iv_get(obj, "arguments"); + eargs = rb_attr_get(obj, rb_intern("arguments")); if (NIL_P(eargs)) { eargs = e->args; } Index: test/ruby/test_enumerator.rb =================================================================== --- test/ruby/test_enumerator.rb (revision 35217) +++ test/ruby/test_enumerator.rb (revision 35218) @@ -1,4 +1,5 @@ require 'test/unit' +require_relative 'envutil' class TestEnumerator < Test::Unit::TestCase def setup @@ -358,6 +359,12 @@ e.inspect) end + def test_inspect_verbose + bug6214 = '[ruby-dev:45449]' + assert_warn("", bug6214) { "".bytes.inspect } + assert_warn("", bug6214) { [].lazy.inspect } + end + def test_generator # note: Enumerator::Generator is a class just for internal g = Enumerator::Generator.new {|y| y << 1 << 2 << 3; :foo } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/