Issue #12140 has been updated by Yui NARUSE.

Backport changed from 2.1: DONTNEED, 2.2: DONTNEED, 2.3: REQUIRED to 2.1: DONTNEED, 2.2: DONTNEED, 2.3: DONE

----------------------------------------
Bug #12140: Serialization of OpenStruct objects with YAML fails
https://bugs.ruby-lang.org/issues/12140#change-57840

* Author: Jorge Manrubia
* Status: Closed
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
* Backport: 2.1: DONTNEED, 2.2: DONTNEED, 2.3: DONE
----------------------------------------
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>'
~~~



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>