From: Marcus Rueckert Date: 2010-10-30T23:14:53+09:00 Subject: [ruby-core:32975] Re: [Ruby 1.9-Bug#4005] YAML fails to roundtrip Time objects On 2010-10-30 23:07:52 +0900, Aaron Patterson wrote: > I'm not able to reproduce this with Syck. Can you try with Psych > instead? Like this: > > ruby -v -ryaml -e 'YAML::ENGINE.yamler = "psych"; t0 = Time.now; p t0; p YAML::load(YAML::dump(t0)) == t0' > > I suspect your error is due to fractional second support. Observe the > output of Syck compared to Psych: > > ### Using Syck > $ ruby -v -ryaml -e 't0 = Time.now; p t0; p YAML::dump(t0)' > > "--- 2010-10-30 07:05:46.535362 -07:00\n" > > ### Using Psych > ruby -v -ryaml -e 'YAML::ENGINE.yamler = "psych"; t0 = Time.now; p t0; p YAML::dump(t0)' > > "--- 2010-10-30 07:06:48.118999000 -07:00\n...\n" $ ruby1.9 -v -ryaml -e 'YAML::ENGINE.yamler = "psych"; t0 = Time.now; p t0; p YAML::load(YAML::dump(t0)) == t0' ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux] /usr/lib64/ruby/1.9.1/psych/deprecated.rb:79: warning: method redefined; discarding old to_yaml_properties /usr/lib64/ruby/1.9.1/syck/rubytypes.rb:13: warning: previous definition of to_yaml_properties was here 2010-10-30 16:11:41 +0200 true $ ruby1.9 -v -ryaml -e 't0 = Time.now; p t0; p YAML::load(YAML::dump(t0)) == t0' ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux] 2010-10-30 16:11:50 +0200 false $ ruby1.9 -v -ryaml -e 'YAML::ENGINE.yamler = "psych"; t0 = Time.now; p t0; p YAML::dump(t0)' ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux] /usr/lib64/ruby/1.9.1/psych/deprecated.rb:79: warning: method redefined; discarding old to_yaml_properties /usr/lib64/ruby/1.9.1/syck/rubytypes.rb:13: warning: previous definition of to_yaml_properties was here 2010-10-30 16:12:39 +0200 "--- 2010-10-30 16:12:39.608620883 +02:00\n...\n" $ ruby1.9 -v -ryaml -e 't0 = Time.now; p t0; p YAML::dump(t0)' ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux] 2010-10-30 16:12:52 +0200 "--- 2010-10-30 16:12:52.775869 +02:00\n" why does psych add the "...\n"? hth darix -- openSUSE - SUSE Linux is my linux openSUSE is good for you www.opensuse.org