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

ruby-changes:22859

From: nobu <ko1@a...>
Date: Mon, 5 Mar 2012 17:12:06 +0900 (JST)
Subject: [ruby-changes:22859] nobu:r34908 (trunk): * ext/syck/lib/syck/rubytypes.rb (Exception.yaml_new): fix bug

nobu	2012-03-05 17:11:48 +0900 (Mon, 05 Mar 2012)

  New Revision: 34908

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

  Log:
    * ext/syck/lib/syck/rubytypes.rb (Exception.yaml_new): fix bug
      that causes YAML serialization problem for Exception.
      Exception#initialize doesn't use visible instance variable for
      the exception message, so call the method with the message.
      patched by Jingwen Owen Ou <jingweno AT gmail.com>.
      http://github.com/ruby/ruby/pull/41

  Modified files:
    trunk/ChangeLog
    trunk/ext/syck/lib/syck/rubytypes.rb
    trunk/test/syck/test_exception.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 34907)
+++ ChangeLog	(revision 34908)
@@ -1,3 +1,12 @@
+Mon Mar  5 17:11:44 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* ext/syck/lib/syck/rubytypes.rb (Exception.yaml_new): fix bug
+	  that causes YAML serialization problem for Exception.
+	  Exception#initialize doesn't use visible instance variable for
+	  the exception message, so call the method with the message.
+	  patched by Jingwen Owen Ou <jingweno AT gmail.com>.
+	  http://github.com/ruby/ruby/pull/41
+
 Mon Mar  5 16:50:22 2012  NAKAMURA Usaku  <usa@r...>
 
 	* test/ruby/test_sleep.rb (TestSleep#test_sleep_5sec): syntax error.
Index: ext/syck/lib/syck/rubytypes.rb
===================================================================
--- ext/syck/lib/syck/rubytypes.rb	(revision 34907)
+++ ext/syck/lib/syck/rubytypes.rb	(revision 34908)
@@ -122,7 +122,8 @@
 class Exception
     yaml_as "tag:ruby.yaml.org,2002:exception"
     def Exception.yaml_new( klass, tag, val )
-        o = YAML.object_maker( klass, { 'mesg' => val.delete( 'message' ) } )
+        o = klass.allocate
+        Exception.instance_method(:initialize).bind(o).call(val.delete('message'))
         val.each_pair do |k,v|
             o.instance_variable_set("@#{k}", v)
         end
Index: test/syck/test_exception.rb
===================================================================
--- test/syck/test_exception.rb	(revision 34907)
+++ test/syck/test_exception.rb	(revision 34908)
@@ -13,7 +13,7 @@
     end
 
     def setup
-      @wups = Wups.new
+      @wups = Wups.new('test_message')
     end
 
     def test_to_yaml

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

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