From eb1eee03ca13eb13f8bfd02f18d9f5a0d5537ca6 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 5 Mar 2012 08:11:48 +0000 Subject: [PATCH] * 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 . http://github.com/ruby/ruby/pull/41 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 +++++++++ ext/syck/lib/syck/rubytypes.rb | 3 ++- test/syck/test_exception.rb | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9ea28c87b8..1088fbc834 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Mon Mar 5 17:11:44 2012 Nobuyoshi Nakada + + * 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 . + http://github.com/ruby/ruby/pull/41 + Mon Mar 5 16:50:22 2012 NAKAMURA Usaku * test/ruby/test_sleep.rb (TestSleep#test_sleep_5sec): syntax error. diff --git a/ext/syck/lib/syck/rubytypes.rb b/ext/syck/lib/syck/rubytypes.rb index eeef156e27..b6869c4b8b 100644 --- a/ext/syck/lib/syck/rubytypes.rb +++ b/ext/syck/lib/syck/rubytypes.rb @@ -122,7 +122,8 @@ end 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 diff --git a/test/syck/test_exception.rb b/test/syck/test_exception.rb index b85cabcd6b..b8ac14e293 100644 --- a/test/syck/test_exception.rb +++ b/test/syck/test_exception.rb @@ -13,7 +13,7 @@ module Syck end def setup - @wups = Wups.new + @wups = Wups.new('test_message') end def test_to_yaml