From: shibata.hiroshi@... Date: 2016-06-24T06:46:04+00:00 Subject: [ruby-core:76129] [Ruby trunk Bug#12451][Rejected] ruby yaml strangely parses string as fixnum Issue #12451 has been updated by Hiroshi SHIBATA. Status changed from Open to Rejected Assignee set to Aaron Patterson ---------------------------------------- Bug #12451: ruby yaml strangely parses string as fixnum https://bugs.ruby-lang.org/issues/12451#change-59333 * Author: David Watzke * Status: Rejected * Priority: Normal * Assignee: Aaron Patterson * ruby -v: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux] * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- Hi, I have stumbled upon a weird behavior of the yaml parser in ruby - older versions (1.8.7, 2.1.5), even latest 2.3.1. The value 1,2 should be a string even if unquoted as the quotes are optional for strings. However in ruby this is not the case (see below), so if you load yaml file and native ruby data structures and then serialize it into yaml again, you get something else. $ cat /tmp/x.yaml --- x: 1,2 $ irb irb(main):001:0> require 'yaml' => true irb(main):002:0> thing = YAML.load_file('x.yaml') => {"x"=>12} irb(main):004:0> thing["x"] => 12 irb(main):006:0> thing["x"].class => Fixnum irb(main):008:0> File.open('/tmp/y.yml', 'w') {|f| f.write thing.to_yaml } => 10 $ cat /tmp/y.yml --- x: 12 In Python, this works as expected: >>> with open("/tmp/x.yaml", 'r') as stream: ... print(yaml.load(stream)) ... {'x': '1,2'} -- https://bugs.ruby-lang.org/ Unsubscribe: