YAML bug with : in strings?

$ irb
irb(main):001:0> require 'yaml'
=> true
irb(main):002:0> YAML::load(":not_a_symbol".to_yaml).class
=> Symbol

The original object was a string starting with ':', not a symbol.

Guillaume.

you can get around this (if it is not a bug) by quoting the string:

   [nrt@bligh filters]$ ruby -r yaml -e 'p YAML::load(%q(":not_a_symbol").to_yaml).class'
   String

regards.

-a

···

On Sat, 23 Oct 2004, Guillaume Marcais wrote:

$ irb
irb(main):001:0> require 'yaml'
=> true
irb(main):002:0> YAML::load(":not_a_symbol".to_yaml).class
=> Symbol

The original object was a string starting with ':', not a symbol.

Guillaume.

--

EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
When you do something, you should burn yourself completely, like a good
bonfire, leaving no trace of yourself. --Shunryu Suzuki

===============================================================================

Guillaume Marcais wrote:

$ irb
irb(main):001:0> require 'yaml'
=> true
irb(main):002:0> YAML::load(":not_a_symbol".to_yaml).class
=> Symbol

The original object was a string starting with ':', not a symbol.

Guillaume.

What version? I get String:

$ ruby -v -r yaml -e 'p YAML::load(":not_a_symbol".to_yaml).class'
ruby 1.9.0 (2004-10-17) [i686-linux]
String

The string has been escaped by #to_yaml

$ ruby -r yaml -e 'puts ":not_a_symbol".to_yaml'
--- ":not_a_symbol"

Guillaume Marcais wrote:
> $ irb
> irb(main):001:0> require 'yaml'
> => true
> irb(main):002:0> YAML::load(":not_a_symbol".to_yaml).class
> => Symbol
>
> The original object was a string starting with ':', not a symbol.
>
> Guillaume.

What version? I get String:

I guess I should have given the version in my original post:

$ irb -v
irb 0.9(02/07/03)
$ ruby -v
ruby 1.8.1 (2004-04-05) [i686-linux]

$ ruby -v -r yaml -e 'p YAML::load(":not_a_symbol".to_yaml).class'
ruby 1.9.0 (2004-10-17) [i686-linux]
String

Good. It has been fixed.

The string has been escaped by #to_yaml

$ ruby -r yaml -e 'puts ":not_a_symbol".to_yaml'
--- ":not_a_symbol"

The problem was loading, not emitting:
$ ruby -v -ryaml -e 'puts ":not_a_symbol".to_yaml'
ruby 1.8.1 (2004-04-05) [i686-linux]
--- ":not_a_symbol"

$ ruby -v -ryaml -e 'puts YAML::load("--- \":not_a_symbol\"").class'
ruby 1.8.1 (2004-04-05) [i686-linux]
Symbol

Thanks,
Guillaume.

···

On Fri, 2004-10-22 at 17:19, Joel VanderWerf wrote: