Problem with yaml and lines beginning with a colon

X

Xavier

Hi all,

For some reason, yaml reads strings beginning with a colon as symbols
which leads to 'cannot dup symbol' exceptions.

$ ruby -v
ruby 1.8.1 (2004-04-24) [i686-linux-gnu]

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

Note the first string has a leading space and the second has not. The
latter is not read back correctly.


Is this is a bug?
Does anyone know a workaround?

Thanks.
 
R

Richard Lionheart

Hi,

Please ignore this reply. I'm just testing whether I can post a reply and
then view it using Outlook Express.

Regards,
Richard


Xavier said:
Hi all,

For some reason, yaml reads strings beginning with a colon as symbols
which leads to 'cannot dup symbol' exceptions.

$ ruby -v
ruby 1.8.1 (2004-04-24) [i686-linux-gnu]

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

Note the first string has a leading space and the second has not. The
latter is not read back correctly.


Is this is a bug?
Does anyone know a workaround?

Thanks.
 
W

why the lucky stiff

Xavier said:
irb(main):003:0> YAML::load(":0 local".to_yaml)
=> :"0 local"

Is this is a bug?
Does anyone know a workaround?
This is a bug in Ruby CVS. Has been since Apr 3. For now, you can
checkout a copy of 1.8 previous to that (including the 1.8.1 release).
I'll report back when I have a fix.

_why
 
X

Xavier

This is a bug in Ruby CVS. Has been since Apr 3. For now, you can
checkout a copy of 1.8 previous to that (including the 1.8.1 release).
I'll report back when I have a fix.

_why

You remark helped me locate where strings with a leading colon
become a symbol. I'll just remove that bit until the problem is fixed. I
know I will not use symbols.


Thanks for your support.
 
W

why the lucky stiff

Xavier said:
Hi all,

For some reason, yaml reads strings beginning with a colon as symbols
which leads to 'cannot dup symbol' exceptions.

irb(main):003:0> YAML::load(":0 local".to_yaml)
=> :"0 local"

Just wanted to followup and say that this is fixed in CVS. Symbol
loading is much improved now. Thankyou.

_why
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,742
Latest member
AshliMayer

Latest Threads

Top