[前][次][番号順一覧][スレッド一覧]

ruby-changes:40319

From: nobu <ko1@a...>
Date: Sat, 31 Oct 2015 10:23:01 +0900 (JST)
Subject: [ruby-changes:40319] nobu:r52400 (trunk): eval_error.c: Fix a format of `NameError#message`

nobu	2015-10-31 10:22:51 +0900 (Sat, 31 Oct 2015)

  New Revision: 52400

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52400

  Log:
    eval_error.c: Fix a format of `NameError#message`
    
    * eval_error.c (undef_mesg_for): fix typo.  Before this commit
      `ArgumentError: malformed format string - %$` was raised when
      `NameError#message` is called.  [ruby-core:71282] [Bug #11640]
      [Fix GH-1077]

  Modified files:
    trunk/ChangeLog
    trunk/eval_error.c
    trunk/test/ruby/test_exception.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52399)
+++ ChangeLog	(revision 52400)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Oct 31 10:22:49 2015  yui-knk  <spiketeika@g...>
+
+	* eval_error.c (undef_mesg_for): fix typo.  Before this commit
+	  `ArgumentError: malformed format string - %$` was raised when
+	  `NameError#message` is called.  [ruby-core:71282] [Bug #11640]
+	  [Fix GH-1077]
+
 Fri Oct 30 21:12:45 2015  Kazuki Tsujimoto  <kazuki@c...>
 
 	* gems/bundled_gems: update to power_assert 0.2.5.
Index: eval_error.c
===================================================================
--- eval_error.c	(revision 52399)
+++ eval_error.c	(revision 52400)
@@ -208,7 +208,7 @@ ruby_error_print(void) https://github.com/ruby/ruby/blob/trunk/eval_error.c#L208
     error_print();
 }
 
-#define undef_mesg_for(v, k) rb_fstring_cstr("undefined"v" method `%1$s' for "k" `%$s'")
+#define undef_mesg_for(v, k) rb_fstring_cstr("undefined"v" method `%1$s' for "k" `%2$s'")
 #define undef_mesg(v) ( \
 	is_mod ? \
 	undef_mesg_for(v, "module") : \
Index: test/ruby/test_exception.rb
===================================================================
--- test/ruby/test_exception.rb	(revision 52399)
+++ test/ruby/test_exception.rb	(revision 52400)
@@ -721,4 +721,16 @@ $stderr = $stdout; raise "\x82\xa0"') do https://github.com/ruby/ruby/blob/trunk/test/ruby/test_exception.rb#L721
     assert_raise(NameError) {a.instance_eval("foo")}
     assert_raise(NoMethodError, bug10969) {a.public_send("bar", true)}
   end
+
+  def test_message_of_name_error
+    begin
+      Module.new do
+        module_function :foo
+      end
+    rescue => e
+      error = e
+    end
+
+    assert_match /\Aundefined method `foo' for module `#<Module:.*>'\z/, error.message
+  end
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]