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

Fix symbolize_name with non-string keys #480

Merged
merged 1 commit into from
May 10, 2021

Conversation

casperisfine
Copy link

Reported to me by @peterthesling.

Simple repro:

>> Psych.load('1: 2', symbolize_names: true)
Traceback (most recent call last):
       16: from /opt/rubies/2.7.2/lib/ruby/gems/2.7.0/gems/irb-1.2.6/exe/irb:11:in `<top (required)>'
       15: from (irb):3
       14: from /Users/byroot/.gem/ruby/2.7.2/gems/psych-3.3.1/lib/psych.rb:282:in `load'
       13: from /Users/byroot/.gem/ruby/2.7.2/gems/psych-3.3.1/lib/psych/nodes/node.rb:50:in `to_ruby'
       12: from /Users/byroot/.gem/ruby/2.7.2/gems/psych-3.3.1/lib/psych/visitors/to_ruby.rb:35:in `accept'
       11: from /Users/byroot/.gem/ruby/2.7.2/gems/psych-3.3.1/lib/psych/visitors/visitor.rb:6:in `accept'
       10: from /Users/byroot/.gem/ruby/2.7.2/gems/psych-3.3.1/lib/psych/visitors/visitor.rb:30:in `visit'
        9: from /Users/byroot/.gem/ruby/2.7.2/gems/psych-3.3.1/lib/psych/visitors/to_ruby.rb:318:in `visit_Psych_Nodes_Document'
        8: from /Users/byroot/.gem/ruby/2.7.2/gems/psych-3.3.1/lib/psych/visitors/to_ruby.rb:35:in `accept'
        7: from /Users/byroot/.gem/ruby/2.7.2/gems/psych-3.3.1/lib/psych/visitors/visitor.rb:6:in `accept'
        6: from /Users/byroot/.gem/ruby/2.7.2/gems/psych-3.3.1/lib/psych/visitors/visitor.rb:30:in `visit'
        5: from /Users/byroot/.gem/ruby/2.7.2/gems/psych-3.3.1/lib/psych/visitors/to_ruby.rb:167:in `visit_Psych_Nodes_Mapping'
        4: from /Users/byroot/.gem/ruby/2.7.2/gems/psych-3.3.1/lib/psych/visitors/to_ruby.rb:343:in `revive_hash'
        3: from /Users/byroot/.gem/ruby/2.7.2/gems/psych-3.3.1/lib/psych/visitors/to_ruby.rb:343:in `each_slice'
        2: from /Users/byroot/.gem/ruby/2.7.2/gems/psych-3.3.1/lib/psych/visitors/to_ruby.rb:343:in `each'
        1: from /Users/byroot/.gem/ruby/2.7.2/gems/psych-3.3.1/lib/psych/visitors/to_ruby.rb:370:in `block in revive_hash'
NoMethodError (undefined method `to_sym' for 1:Integer)
Did you mean?  to_s

I went all the way back to when the feature was introduced (88ad4d50) and apparently it was already failing back then.

cc @tenderlove

@casperisfine casperisfine changed the title Fix symabolize_name with non-string keys Fix symbolize_name with non-string keys Mar 10, 2021
@hsbt hsbt merged commit 8fcdc38 into ruby:master May 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants