Skip to content

Commit acc55c2

Browse files
committed
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
1 parent c31e7c1 commit acc55c2

File tree

4 files changed

+67
-5
lines changed

4 files changed

+67
-5
lines changed

ChangeLog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
Tue Mar 6 12:05:42 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
2+
3+
* lib/yaml/rubytypes.rb (Exception.yaml_new): fix bug that causes
4+
YAML serialization problem for Exception.
5+
Exception#initialize doesn't use visible instance variable for
6+
the exception message, so call the method with the message.
7+
patched by Jingwen Owen Ou <jingweno AT gmail.com>.
8+
http://github.com/ruby/ruby/pull/41
9+
110
Fri Mar 2 11:44:33 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
211

312
* marshal.c (mark_dump_arg): mark destination string. patch by

lib/yaml/rubytypes.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ def to_yaml( opts = {} )
117117
class Exception
118118
yaml_as "tag:ruby.yaml.org,2002:exception"
119119
def Exception.yaml_new( klass, tag, val )
120-
o = YAML.object_maker( klass, { 'mesg' => val.delete( 'message' ) } )
120+
o = klass.allocate
121+
Exception.instance_method(:initialize).bind(o).call(val.delete('message'))
121122
val.each_pair do |k,v|
122123
o.instance_variable_set("@#{k}", v)
123124
end

test/yaml/test_exception.rb

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
require 'test/unit'
2+
require 'yaml'
3+
4+
module Syck
5+
class TestException < Test::Unit::TestCase
6+
class Wups < Exception
7+
attr_reader :foo, :bar
8+
def initialize *args
9+
super
10+
@foo = 1
11+
@bar = 2
12+
end
13+
14+
def ==(other)
15+
self.class == other.class and
16+
self.message == other.message and
17+
self.backtrace == other.backtrace
18+
end
19+
end
20+
21+
def setup
22+
@wups = Wups.new('test_message')
23+
end
24+
25+
def test_to_yaml
26+
w = YAML.load(@wups.to_yaml)
27+
assert_equal @wups, w
28+
assert_equal 1, w.foo
29+
assert_equal 2, w.bar
30+
end
31+
32+
def test_dump
33+
w = YAML.load(@wups.to_yaml)
34+
assert_equal @wups, w
35+
assert_equal 1, w.foo
36+
assert_equal 2, w.bar
37+
end
38+
39+
def test_to_yaml_properties
40+
class << @wups
41+
def to_yaml_properties
42+
[:@foo]
43+
end
44+
end
45+
46+
w = YAML.load(YAML.dump(@wups))
47+
assert_equal @wups, w
48+
assert_equal 1, w.foo
49+
assert_nil w.bar
50+
end
51+
end
52+
end

version.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#define RUBY_VERSION "1.8.7"
2-
#define RUBY_RELEASE_DATE "2012-03-02"
2+
#define RUBY_RELEASE_DATE "2012-03-06"
33
#define RUBY_VERSION_CODE 187
4-
#define RUBY_RELEASE_CODE 20120302
5-
#define RUBY_PATCHLEVEL 359
4+
#define RUBY_RELEASE_CODE 20120306
5+
#define RUBY_PATCHLEVEL 360
66

77
#define RUBY_VERSION_MAJOR 1
88
#define RUBY_VERSION_MINOR 8
99
#define RUBY_VERSION_TEENY 7
1010
#define RUBY_RELEASE_YEAR 2012
1111
#define RUBY_RELEASE_MONTH 3
12-
#define RUBY_RELEASE_DAY 2
12+
#define RUBY_RELEASE_DAY 6
1313

1414
#ifdef RUBY_EXTERN
1515
RUBY_EXTERN const char ruby_version[];

0 commit comments

Comments
 (0)