Ross Bamford
6/4/2006 10:34:00 AM
On Sun, 04 Jun 2006 11:09:58 +0100, Robert Klemme <bob.news@gmx.net> wrote:
> Frantisek Fuka wrote:
>> Version is: ruby 1.8.4 (2005-12-24) [i486-linux]
>> The code is rather simple:
>> str=File.open(fname).read
>
> Again, here you do not close the file handle properly. When reading
> from a file you can also use
>
> data = YAML.load_file fname
>
Hmm, the behaviour I'm seeing here would suggest this to be a bug. With
load_file, sometimes it works, sometimes it doesn't. Loading the file in
Ruby and passing it in always fails.
$ ruby -v
ruby 1.8.4 (2005-12-24) [i686-linux]
$ irb -ryaml
YAML::Syck::VERSION
# => "0.60"
YAML::load(File.read('test.yaml'))
ArgumentError: syntax error on line 50, col 57: `C3\xBD, Denisi."
- ""
- "Z\xC3\xA1\xC5\x99n\xC3\xB'
from /usr/local/lib/ruby/1.8/yaml.rb:133:in `load'
from /usr/local/lib/ruby/1.8/yaml.rb:133:in `load'
from (irb):3
YAML::load_file('test.yaml')
ArgumentError: syntax error on line 50, col 57: `C3\xBD, Denisi."
- ""
- "Z\xC3\xA1\xC5\x99n\xC3\xB'
from /usr/local/lib/ruby/1.8/yaml.rb:133:in `load'
from /usr/local/lib/ruby/1.8/yaml.rb:133:in `load'
from /usr/local/lib/ruby/1.8/yaml.rb:144:in `load_file'
from /usr/local/lib/ruby/1.8/yaml.rb:143:in `load_file'
from (irb):5
YAML::load_file('test.yaml')
# => {:subtitles=>[ ... 49 elements ... ]}
YAML::load_file('test.yaml')
ArgumentError: syntax error on line 50, col 57: `C3\xBD, Denisi."
- ""
- "Z\xC3\xA1\xC5\x99n\xC3\xB'
from /usr/local/lib/ruby/1.8/yaml.rb:133:in `load'
from /usr/local/lib/ruby/1.8/yaml.rb:133:in `load'
from /usr/local/lib/ruby/1.8/yaml.rb:144:in `load_file'
from /usr/local/lib/ruby/1.8/yaml.rb:143:in `load_file'
from (irb):7
YAML::load_file('test.yaml')
# => {:subtitles=>[ ... 49 elements ... ]}
YAML::load_file('test.yaml')
# => {:subtitles=>[ ... 49 elements ... ]}
YAML::load_file('test.yaml')
# => {:subtitles=>[ ... 49 elements ... ]}
--
Ross Bamford - rosco@roscopeco.remove.co.uk