ruby-changes:22870
From: nobu <ko1@a...>
Date: Tue, 6 Mar 2012 12:03:49 +0900 (JST)
Subject: [ruby-changes:22870] nobu:r34919 (ruby_1_8): merge revision(s) 34908:
nobu 2012-03-06 12:03:37 +0900 (Tue, 06 Mar 2012) New Revision: 34919 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34919 Log: merge revision(s) 34908: * 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/test/yaml/test_exception.rb Modified files: branches/ruby_1_8/ChangeLog branches/ruby_1_8/lib/yaml/rubytypes.rb branches/ruby_1_8/version.h Index: ruby_1_8/ChangeLog =================================================================== --- ruby_1_8/ChangeLog (revision 34918) +++ ruby_1_8/ChangeLog (revision 34919) @@ -1,3 +1,12 @@ +Tue Mar 6 12:03:33 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 10:53:01 2012 Nobuyoshi Nakada <nobu@r...> * marshal.c (mark_dump_arg): mark destination string. patch by Index: ruby_1_8/version.h =================================================================== --- ruby_1_8/version.h (revision 34918) +++ ruby_1_8/version.h (revision 34919) @@ -1,7 +1,7 @@ #define RUBY_VERSION "1.8.8" -#define RUBY_RELEASE_DATE "2012-03-02" +#define RUBY_RELEASE_DATE "2012-03-06" #define RUBY_VERSION_CODE 188 -#define RUBY_RELEASE_CODE 20120302 +#define RUBY_RELEASE_CODE 20120306 #define RUBY_PATCHLEVEL -1 #define RUBY_VERSION_MAJOR 1 @@ -9,7 +9,7 @@ #define RUBY_VERSION_TEENY 8 #define RUBY_RELEASE_YEAR 2012 #define RUBY_RELEASE_MONTH 3 -#define RUBY_RELEASE_DAY 2 +#define RUBY_RELEASE_DAY 6 #define NO_STRING_LITERAL_CONCATENATION 1 #ifdef RUBY_EXTERN Index: ruby_1_8/lib/yaml/rubytypes.rb =================================================================== --- ruby_1_8/lib/yaml/rubytypes.rb (revision 34918) +++ ruby_1_8/lib/yaml/rubytypes.rb (revision 34919) @@ -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/test/yaml/test_exception.rb =================================================================== --- ruby_1_8/test/yaml/test_exception.rb (revision 0) +++ ruby_1_8/test/yaml/test_exception.rb (revision 34919) @@ -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/test/yaml/test_exception.rb ___________________________________________________________________ Added: svn:eol-style + LF -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/