Hi. Caleb Tennis <caleb / aei-tech.com> wrote: (2005/12/31 03:57) >On Saturday 17 December 2005 22:18, Ryan Davis wrote: >> I'm concerned that 1.8.3's acceptance of non-backwards-compatible >> changes to YAML is setting a bad precedence for ruby release >> management. I don't think that point (read: bug-fix) releases should >> accept and release anything that would break compatibility with >> versions of the same major.minor value. Further, I don't think that >> backwards incompatibility should be introduced on minor revs without >> a minor rev in-between marking such a feature as deprecated. > >Note that there is still another unfixed-as-of-1.8.4 YAML change: > >http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/6115 > >http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/6159 (Proposed >patch) > >Caleb This patch seems to be working. But I'm not familier with yaml, so can anyone test this? (I found another problem on Numeric. Rational and Complex are not treated properly) If there is no objection, I want to commit this. Index: lib/yaml/rubytypes.rb =================================================================== RCS file: /src/ruby/lib/yaml/rubytypes.rb,v retrieving revision 1.16.2.9 diff -u -p -r1.16.2.9 rubytypes.rb --- lib/yaml/rubytypes.rb 20 Sep 2005 06:46:45 -0000 1.16.2.9 +++ lib/yaml/rubytypes.rb 3 Jan 2006 07:32:12 -0000 @@ -352,7 +352,17 @@ class Date end end -class Numeric +class Integer + yaml_as "tag:yaml.org,2002:int" + def to_yaml( opts = {} ) + YAML::quick_emit( nil, opts ) do |out| + out.scalar( "tag:yaml.org,2002:int", self.to_s, :plain ) + end + end +end + +class Float + yaml_as "tag:yaml.org,2002:float" def to_yaml( opts = {} ) YAML::quick_emit( nil, opts ) do |out| str = self.to_s @@ -363,19 +373,11 @@ class Numeric elsif str == "NaN" str = ".NaN" end - out.scalar( taguri, str, :plain ) + out.scalar( "tag:yaml.org,2002:float", str, :plain ) end end end -class Fixnum - yaml_as "tag:yaml.org,2002:int" -end - -class Float - yaml_as "tag:yaml.org,2002:float" -end - class TrueClass yaml_as "tag:yaml.org,2002:bool#yes" def to_yaml( opts = {} ) ///////////////////////////////// // test require 'yaml' def test(o) y = YAML.dump(o) o = YAML.load(y) p [y, o, o.class] end test(1) test(11111111111111111111111) test(1.2) require 'rational' test(Rational(2, 3)) require 'complex' test(Complex(1, 2)) test(Complex(1.2, 2.0 / 0.0)) ///////////////////////////////// // ruby 1.8.2 ["--- 1", 1, Fixnum] ["--- 11111111111111111111111", 11111111111111111111111, Bignum] ["--- 1.2", 1.2, Float] ["--- 2/3", "2/3", String] ["--- 1+2i", "1+2i", String] ["--- 1.2+Infinityi", "1.2+Infinityi", String] ///////////////////////////////// // ruby 1.8.4 ["--- 1\n", 1, Fixnum] # failed on bignum ["--- 1.2\n", 1.2, Float] ["--- !ruby/object:Rational 2/3\n", Rational(nil, nil), Rational] ["--- !ruby/object:Complex 1+2i\n", Complex(nil, nil), Complex] ["--- !ruby/object:Complex 1.2+Infinityi\n", Complex(nil, nil), Complex] ///////////////////////////////// // ruby_1_8 + patch ["--- 1\n", 1, Fixnum] ["--- 11111111111111111111111\n", 11111111111111111111111, Bignum] ["--- 1.2\n", 1.2, Float] ["--- !ruby/object:Rational \ndenominator: 3\nnumerator: 2\n", Rational(2, 3), R ational] ["--- !ruby/object:Complex \nimage: 2\nreal: 1\n", Complex(1, 2), Complex] ["--- !ruby/object:Complex \nimage: .Inf\nreal: 1.2\n", Complex(1.2, Infinity), Complex]