[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

YAML bug with : in strings?

Guillaume Marcais

10/22/2004 8:47:00 PM

$ 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.



3 Answers

Ara.T.Howard

10/22/2004 9:02:00 PM

0

Joel VanderWerf

10/22/2004 9:20:00 PM

0

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

10/22/2004 10:34:00 PM

0

On Fri, 2004-10-22 at 17:19, Joel VanderWerf wrote:
> 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.