From: Zachary Scott Date: 2012-08-14T03:12:58+09:00 Subject: [ruby-core:47156] Re: [ruby-trunk - Bug #6849][Open] Psych.load_file throws TypeError for empty file On ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux] I can reproduce this using Psych.load_file. However, when I try Psych#load as the implementation suggests[1] leaving out the utf stuff "bom|utf-8"; it returns false: $irb require 'psych' `touch empty.yml` File.open('empty.yml', 'r') { |f| Psych.load(f,'empty file') } #=> false Something is up with the File.open mode used by psych: $irb `touch empty.file` File.open('empty.file', 'r:bom|utf-8') { |f| puts f } TypeError: no implicit conversion from nil to integer 1: https://github.com/tenderlove/psych/blob/master/lib/psych.rb#L299 On Thu, Aug 9, 2012 at 2:54 PM, BrandonMathis (Brandon Mathis) wrote: > > Issue #6849 has been reported by BrandonMathis (Brandon Mathis). > > ---------------------------------------- > Bug #6849: Psych.load_file throws TypeError for empty file > https://bugs.ruby-lang.org/issues/6849 > > Author: BrandonMathis (Brandon Mathis) > Status: Open > Priority: Normal > Assignee: > Category: > Target version: > ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.0.0] > > > When parsing an empty file via Psych.load_file: > TypeError: no implicit conversion from nil to integer > I would expect that an empty hash or array would be returned. > > This, more directly, relates to parsing YAML documents using YAML.load_file > > > -- > http://bugs.ruby-lang.org/ >