Project

General

Profile

Bug #16368

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

Added by kibitan (Chikahiro Tokoro) 2 months ago.

Status:
Open
Priority:
Normal
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

Also available in: Atom PDF