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

ruby-changes:22871

From: nobu <ko1@a...>
Date: Tue, 6 Mar 2012 12:06:28 +0900 (JST)
Subject: [ruby-changes:22871] nobu:r34920 (ruby_1_8_7): merge revision(s) 34919:

nobu	2012-03-06 12:06:11 +0900 (Tue, 06 Mar 2012)

  New Revision: 34920

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

  Log:
    merge revision(s) 34919:
    
    * lib/yaml/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

  Added files:
    branches/ruby_1_8_7/test/yaml/test_exception.rb
  Modified files:
    branches/ruby_1_8_7/ChangeLog
    branches/ruby_1_8_7/lib/yaml/rubytypes.rb
    branches/ruby_1_8_7/version.h

Index: ruby_1_8_7/ChangeLog
===================================================================
--- ruby_1_8_7/ChangeLog	(revision 34919)
+++ ruby_1_8_7/ChangeLog	(revision 34920)
@@ -1,3 +1,12 @@
+Tue Mar  6 12:05:42 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* lib/yaml/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
+
 Fri Mar  2 11:44:33 2012  Nobuyoshi Nakada  <nobu@r...>
 
 	* marshal.c (mark_dump_arg): mark destination string.  patch by
Index: ruby_1_8_7/version.h
===================================================================
--- ruby_1_8_7/version.h	(revision 34919)
+++ ruby_1_8_7/version.h	(revision 34920)
@@ -1,15 +1,15 @@
 #define RUBY_VERSION "1.8.7"
-#define RUBY_RELEASE_DATE "2012-03-02"
+#define RUBY_RELEASE_DATE "2012-03-06"
 #define RUBY_VERSION_CODE 187
-#define RUBY_RELEASE_CODE 20120302
-#define RUBY_PATCHLEVEL 359
+#define RUBY_RELEASE_CODE 20120306
+#define RUBY_PATCHLEVEL 360
 
 #define RUBY_VERSION_MAJOR 1
 #define RUBY_VERSION_MINOR 8
 #define RUBY_VERSION_TEENY 7
 #define RUBY_RELEASE_YEAR 2012
 #define RUBY_RELEASE_MONTH 3
-#define RUBY_RELEASE_DAY 2
+#define RUBY_RELEASE_DAY 6
 
 #ifdef RUBY_EXTERN
 RUBY_EXTERN const char ruby_version[];
Index: ruby_1_8_7/lib/yaml/rubytypes.rb
===================================================================
--- ruby_1_8_7/lib/yaml/rubytypes.rb	(revision 34919)
+++ ruby_1_8_7/lib/yaml/rubytypes.rb	(revision 34920)
@@ -117,7 +117,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: ruby_1_8_7/test/yaml/test_exception.rb
===================================================================
--- ruby_1_8_7/test/yaml/test_exception.rb	(revision 0)
+++ ruby_1_8_7/test/yaml/test_exception.rb	(revision 34920)
@@ -0,0 +1,52 @@
+require 'test/unit'
+require 'yaml'
+
+module Syck
+  class TestException < Test::Unit::TestCase
+    class Wups < Exception
+      attr_reader :foo, :bar
+      def initialize *args
+        super
+        @foo = 1
+        @bar = 2
+      end
+
+      def ==(other)
+        self.class == other.class and
+          self.message == other.message and
+          self.backtrace == other.backtrace
+      end
+    end
+
+    def setup
+      @wups = Wups.new('test_message')
+    end
+
+    def test_to_yaml
+      w = YAML.load(@wups.to_yaml)
+      assert_equal @wups, w
+      assert_equal 1, w.foo
+      assert_equal 2, w.bar
+    end
+
+    def test_dump
+      w = YAML.load(@wups.to_yaml)
+      assert_equal @wups, w
+      assert_equal 1, w.foo
+      assert_equal 2, w.bar
+    end
+
+    def test_to_yaml_properties
+      class << @wups
+        def to_yaml_properties
+          [:@foo]
+        end
+      end
+
+      w = YAML.load(YAML.dump(@wups))
+      assert_equal @wups, w
+      assert_equal 1, w.foo
+      assert_nil w.bar
+    end
+  end
+end

Property changes on: ruby_1_8_7/test/yaml/test_exception.rb
___________________________________________________________________
Added: svn:eol-style
   + LF


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

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