Project

General

Profile

Actions

Bug #16368

closed

Error in `YAML.load(symbolize_names: true)` with null column YAML

Added by kibitan (Chikahiro Tokoro) over 4 years ago. Updated almost 3 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.0preview2 (2019-10-22 master 02aadf1032) [x86_64-linux]
[ruby-core:95944]
Tags:

Description

Trying to parse YAML which contains null column symbolize_names: true would raise NoMethodError

irb(main):001:0> require 'yaml'
=> true
irb(main):002:0> YAML.load("null: nullnull")
=> {nil=>"nullnull"}
irb(main):003:0> YAML.load("null: nullnull", symbolize_names: true)
Traceback (most recent call last):
        8: from /usr/local/bin/irb:23:in `<main>'
        7: from /usr/local/bin/irb:23:in `load'
        6: from /usr/local/lib/ruby/gems/2.7.0/gems/irb-1.1.0.pre.3/exe/irb:11:in `<top (required)>'
        5: from (irb):4
        4: from /usr/local/lib/ruby/2.7.0/psych.rb:276:in `load'
        3: from /usr/local/lib/ruby/2.7.0/psych.rb:606:in `symbolize_names!'
        2: from /usr/local/lib/ruby/2.7.0/psych.rb:606:in `each'
        1: from /usr/local/lib/ruby/2.7.0/psych.rb:607:in `block in symbolize_names!'
NoMethodError (undefined method `to_sym' for nil:NilClass

I also send a pull request for related repo.
https://github.com/ruby/psych/pull/423

Updated by jeremyevans0 (Jeremy Evans) almost 3 years ago

  • Status changed from Open to Closed

https://github.com/ruby/psych/pull/480 was merged, which fixed this issue.

Actions

Also available in: Atom PDF

Like0
Like0