Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not play well with Ruby 2 YAML serialization #3

Open
gerryster opened this issue Aug 10, 2016 · 0 comments
Open

Does not play well with Ruby 2 YAML serialization #3

gerryster opened this issue Aug 10, 2016 · 0 comments

Comments

@gerryster
Copy link

The encoder is not correctly initialized when insensitive hash objects are deserialized using psych which is shipped with Ruby 2. Here is an example on Ruby 2.3.1p112:

irb(main):011:0> Psych.load(Psych.dump({a: 1}))
=> {:a=>1}
irb(main):012:0> Psych.load(Psych.dump({a: 1}.insensitive))
NoMethodError: undefined method `call' for nil:NilClass
Did you mean?  caller
    from /Users/ryan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/insensitive_hash-0.3.3/lib/insensitive_hash/insensitive_hash.rb:218:in `encode'
    from /Users/ryan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/insensitive_hash-0.3.3/lib/insensitive_hash/insensitive_hash.rb:209:in `lookup_key'
    from /Users/ryan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/insensitive_hash-0.3.3/lib/insensitive_hash/insensitive_hash.rb:127:in `delete'
    from /Users/ryan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/insensitive_hash-0.3.3/lib/insensitive_hash/insensitive_hash.rb:87:in `[]='
    from /Users/ryan/.rbenv/versions/2.3.1/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:362:in `block in revive_hash'
    from /Users/ryan/.rbenv/versions/2.3.1/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:336:in `each'
    from /Users/ryan/.rbenv/versions/2.3.1/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:336:in `each_slice'
    from /Users/ryan/.rbenv/versions/2.3.1/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:336:in `revive_hash'
    from /Users/ryan/.rbenv/versions/2.3.1/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:271:in `block in visit_Psych_Nodes_Mapping'
    from /Users/ryan/.rbenv/versions/2.3.1/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:268:in `each'
    from /Users/ryan/.rbenv/versions/2.3.1/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:268:in `each_slice'
    from /Users/ryan/.rbenv/versions/2.3.1/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:268:in `visit_Psych_Nodes_Mapping'
    from /Users/ryan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/delayed_job-4.0.0/lib/delayed/psych_ext.rb:133:in `visit_Psych_Nodes_Mapping_with_class'
    from /Users/ryan/.rbenv/versions/2.3.1/lib/ruby/2.3.0/psych/visitors/visitor.rb:16:in `visit'
    from /Users/ryan/.rbenv/versions/2.3.1/lib/ruby/2.3.0/psych/visitors/visitor.rb:6:in `accept'
    from /Users/ryan/.rbenv/versions/2.3.1/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:32:in `accept'
    from /Users/ryan/.rbenv/versions/2.3.1/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:311:in `visit_Psych_Nodes_Document'
    from /Users/ryan/.rbenv/versions/2.3.1/lib/ruby/2.3.0/psych/visitors/visitor.rb:16:in `visit'
    from /Users/ryan/.rbenv/versions/2.3.1/lib/ruby/2.3.0/psych/visitors/visitor.rb:6:in `accept'
    from /Users/ryan/.rbenv/versions/2.3.1/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:32:in `accept'
    from /Users/ryan/.rbenv/versions/2.3.1/lib/ruby/2.3.0/psych/nodes/node.rb:38:in `to_ruby'
    from /Users/ryan/.rbenv/versions/2.3.1/lib/ruby/2.3.0/psych.rb:253:in `load'
    from (irb):12
    from /Users/ryan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-3.2.22.2/lib/rails/commands/console.rb:47:in `start'
    from /Users/ryan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-3.2.22.2/lib/rails/commands/console.rb:8:in `start'
    from /Users/ryan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-3.2.22.2/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'
irb(main):013:0>

Notice that this is not an issue on ruby 1.9.3p551:

irb(main):001:0> Psych.load(Psych.dump({a: 1}))
=> {:a=>1}
irb(main):002:0> Psych.load(Psych.dump({a: 1}.insensitive))
=> {:a=>1}

I am using version 0.3.3 of this gem.

@gerryster gerryster changed the title Does not play well with Ruby 2 Does not play well with Ruby 2 YAML serialization Aug 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant