Skip to content

Commit 0b39253

Browse files
committed
* ext/psych/lib/psych/visitors/to_ruby.rb: backwards compatibility for
hashes emitted by Syck. Github #198 * test/psych/test_hash.rb: test for change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 9670542 commit 0b39253

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Wed Aug 6 03:41:21 2014 Aaron Patterson <aaron@tenderlovemaking.com>
2+
3+
* ext/psych/lib/psych/visitors/to_ruby.rb: backwards compatibility for
4+
hashes emitted by Syck. Github #198
5+
* test/psych/test_hash.rb: test for change.
6+
17
Tue Aug 5 19:27:59 2014 Masaki Suketa <masaki.suketa@nifty.ne.jp>
28

39
* ext/win32ole/win32ole.c (ole_invoke): skip VariantClear when

ext/psych/lib/psych/visitors/to_ruby.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ def visit_Psych_Nodes_Mapping o
201201
class_loader.rational
202202
h = Hash[*o.children.map { |c| accept c }]
203203
register o, Rational(h['numerator'], h['denominator'])
204+
elsif name == 'Hash'
205+
revive_hash(register(o, {}), o)
204206
else
205207
obj = revive((resolve_class(name) || class_loader.object), o)
206208
obj

test/psych/test_hash.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ def setup
1010
@hash = { :a => 'b' }
1111
end
1212

13+
def test_load_with_class_syck_compatibility
14+
hash = Psych.load "--- !ruby/object:Hash\n:user_id: 7\n:username: Lucas\n"
15+
assert_equal({ user_id: 7, username: 'Lucas'}, hash)
16+
end
17+
1318
def test_empty_subclass
1419
assert_match "!ruby/hash:#{X}", Psych.dump(X.new)
1520
x = Psych.load Psych.dump X.new

0 commit comments

Comments
 (0)