diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-06 03:06:11 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-06 03:06:11 +0000 |
commit | acc55c25c587fef5c7327c5912f3aa50a969ec34 (patch) | |
tree | c8a1bcb549bc6b3a251a3d2c865c17ec1385acd8 | |
parent | c31e7c1e8b2895ef33204938487597e2b3acaaf7 (diff) |
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
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@34920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | lib/yaml/rubytypes.rb | 3 | ||||
-rw-r--r-- | test/yaml/test_exception.rb | 52 | ||||
-rw-r--r-- | version.h | 8 |
4 files changed, 67 insertions, 5 deletions
@@ -1,3 +1,12 @@ +Tue Mar 6 12:05:42 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * 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@ruby-lang.org> * marshal.c (mark_dump_arg): mark destination string. patch by diff --git a/lib/yaml/rubytypes.rb b/lib/yaml/rubytypes.rb index 35b719196e..55d59fa03b 100644 --- a/lib/yaml/rubytypes.rb +++ b/lib/yaml/rubytypes.rb @@ -117,7 +117,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/yaml/test_exception.rb b/test/yaml/test_exception.rb new file mode 100644 index 0000000000..1dc3044a94 --- /dev/null +++ b/test/yaml/test_exception.rb @@ -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 @@ -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[]; |