Actions
Bug #12140
closedSerialization of OpenStruct objects with YAML fails
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
Description
When deserializing a serialized YAML open-struct object, it fails with an exception NoMethodError: undefined method
key?' for nil:NilClass`.
This breaks serialized
attributes in Rails 3.2 with Ruby 2.3.
To reproduce:
require 'ostruct'
require 'yaml'
YAML.load(YAML.dump(OpenStruct.new))
Full exception trace:
NoMethodError: undefined method `key?' for nil:NilClass
from /Users/jorge/.rbenv/versions/2.3.0/lib/ruby/2.3.0/ostruct.rb:176:in `respond_to_missing?'
from /Users/jorge/.rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:381:in `respond_to?'
from /Users/jorge/.rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:381:in `init_with'
from /Users/jorge/.rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:374:in `revive'
from /Users/jorge/.rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:208:in `visit_Psych_Nodes_Mapping'
from /Users/jorge/.rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/visitor.rb:16:in `visit'
from /Users/jorge/.rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/visitor.rb:6:in `accept'
from /Users/jorge/.rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:32:in `accept'
from /Users/jorge/.rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:311:in `visit_Psych_Nodes_Document'
from /Users/jorge/.rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/visitor.rb:16:in `visit'
from /Users/jorge/.rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/visitor.rb:6:in `accept'
from /Users/jorge/.rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:32:in `accept'
from /Users/jorge/.rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/nodes/node.rb:38:in `to_ruby'
from /Users/jorge/.rbenv/versions/2.3.0/lib/ruby/2.3.0/psych.rb:253:in `load'
from (irb):1
from /Users/jorge/.rbenv/versions/2.3.0/bin/irb:11:in `<main>'
Actions
Like0
Like0Like0Like0Like0Like0