1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/psych/lib/psych/visitors/yaml_tree.rb: fix NameError dumping and

loading. Fixes GH #85. Thanks @brentdax for the patch!
* test/psych/test_exception.rb: test for fix

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47319 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tenderlove 2014-08-29 21:41:02 +00:00
parent 8662841a9b
commit 66d3b9750b
3 changed files with 31 additions and 0 deletions

View file

@ -1,3 +1,9 @@
Sat Aug 30 06:39:48 2014 Aaron Patterson <aaron@tenderlovemaking.com>
* ext/psych/lib/psych/visitors/yaml_tree.rb: fix NameError dumping and
loading. Fixes GH #85. Thanks @brentdax for the patch!
* test/psych/test_exception.rb: test for fix
Sat Aug 30 06:23:40 2014 Aaron Patterson <aaron@tenderlovemaking.com>
* ext/psych/lib/psych/scalar_scanner.rb: fix loading strings that

View file

@ -211,6 +211,25 @@ module Psych
@emitter.end_mapping
end
def visit_NameError o
tag = ['!ruby/exception', o.class.name].join ':'
@emitter.start_mapping nil, tag, false, Nodes::Mapping::BLOCK
{
'message' => o.message.to_s,
'backtrace' => private_iv_get(o, 'backtrace'),
}.each do |k,v|
next unless v
@emitter.scalar k, nil, nil, true, false, Nodes::Scalar::ANY
accept v
end
dump_ivars o
@emitter.end_mapping
end
def visit_Regexp o
register o, @emitter.scalar(o.inspect, nil, '!ruby/regexp', false, false, Nodes::Scalar::ANY)
end

View file

@ -16,6 +16,12 @@ module Psych
@wups = Wups.new
end
def test_naming_exception
err = String.xxx rescue $!
new_err = Psych.load(Psych.dump(err))
assert_equal err.message, new_err.message
end
def test_load_takes_file
ex = assert_raises(Psych::SyntaxError) do
Psych.load '--- `'