ruby-changes:23115
From: tenderlove <ko1@a...>
Date: Thu, 29 Mar 2012 10:25:24 +0900 (JST)
Subject: [ruby-changes:23115] tenderlove:r35165 (ruby_1_9_3): merge revision(s) 32578,33401,33403,33404,33531,33655,33679,33809,33900,33965,34067,34069,34087,34328,34330,34527,34772,34783,34839,34914,34953,34954,35153: [Backport #6212]
tenderlove 2012-03-29 10:25:11 +0900 (Thu, 29 Mar 2012) New Revision: 35165 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35165 Log: merge revision(s) 32578,33401,33403,33404,33531,33655,33679,33809,33900,33965,34067,34069,34087,34328,34330,34527,34772,34783,34839,34914,34953,34954,35153: [Backport #6212] * ext/psych/lib/psych.rb: updating version to match gem * ext/psych/psych.gemspec: ditto * ext/psych/lib/psych/visitors/to_ruby.rb: fixing deprecation warning * ext/psych/lib/psych.rb: define a new BadAlias error class. * ext/psych/lib/psych/visitors/to_ruby.rb: raise an exception when deserializing an alias that does not exist. * test/psych/test_merge_keys.rb: corresponding test. * ext/psych/lib/psych.rb (load, parse): stop parsing or loading after the first document has been parsed. * test/psych/test_stream.rb: pertinent tests. * ext/psych/lib/psych.rb (parse_stream, load_stream): if a block is given, documents will be yielded to the block as they are parsed. [ruby-core:42404] [Bug #5978] * ext/psych/lib/psych/handlers/document_stream.rb: add a handler that yields documents as they are parsed * test/psych/test_stream.rb: corresponding tests. * ext/psych/lib/psych/core_ext.rb: only extend Kernel if IRB is loaded in order to stop method pollution. * ext/psych/lib/psych.rb: default open YAML files with utf8 external encoding. [ruby-core:42967] * test/psych/test_tainted.rb: ditto * ext/psych/parser.c: prevent a memory leak by protecting calls to handler callbacks. * test/psych/test_parser.rb: test to demonstrate leak. * ext/psych/parser.c: set parser encoding based on the YAML input rather than user configuration. * test/psych/test_encoding.rb: corresponding tests. * test/psych/test_parser.rb: ditto * test/psych/test_tainted.rb: ditto * ext/psych/parser.c: removed external encoding setter, allow parser to be reused. * ext/psych/lib/psych/parser.rb: added external encoding setter. * test/psych/test_parser.rb: test parser reuse * ext/psych/lib/psych/visitors/to_ruby.rb: Added support for loading subclasses of String with ivars * ext/psych/lib/psych/visitors/yaml_tree.rb: Added support for dumping subclasses of String with ivars * test/psych/test_string.rb: corresponding tests * ext/psych/lib/psych/visitors/to_ruby.rb: Added ability to load array subclasses with ivars. * ext/psych/lib/psych/visitors/yaml_tree.rb: Added ability to dump array subclasses with ivars. * test/psych/test_array.rb: corresponding tests * ext/psych/emitter.c: fixing clang warnings. Thanks Joey! * ext/psych/lib/psych/visitors/to_ruby.rb: BigDecimals can be restored from YAML. * ext/psych/lib/psych/visitors/yaml_tree.rb: BigDecimals can be dumped to YAML. * test/psych/test_numeric.rb: tests for BigDecimal serialization * ext/psych/lib/psych/scalar_scanner.rb: Strings that look like dates should be treated as strings and not dates. * test/psych/test_scalar_scanner.rb: corresponding tests. * ext/psych/lib/psych.rb (module Psych): parse and load methods take an optional file name that is used when raising Psych::SyntaxError exceptions * ext/psych/lib/psych/syntax_error.rb (module Psych): allow nil file names and handle nil file names in the exception message * test/psych/test_exception.rb (module Psych): Tests for changes. * ext/psych/parser.c (parse): parse method can take an option file name for use in exception messages. * test/psych/test_parser.rb: corresponding tests. * ext/psych/lib/psych.rb: remove autoload from psych * ext/psych/lib/psych/json.rb: ditto * ext/psych/lib/psych/tree_builder.rb: dump complex numbers, rationals, etc with reference ids. * ext/psych/lib/psych/visitors/yaml_tree.rb: ditto * ext/psych/lib/psych/visitors/to_ruby.rb: loading complex numbers, rationals, etc with reference ids. * test/psych/test_object_references.rb: corresponding tests * ext/psych/lib/psych/scalar_scanner.rb: make sure strings that look like base 60 numbers are serialized as quoted strings. * test/psych/test_string.rb: test for change. * ext/psych/parser.c: remove unused variable. * ext/psych/lib/psych/syntax_error.rb: Add file, line, offset, and message attributes during parse failure. * ext/psych/parser.c: Update parser to raise exception with correct values. * test/psych/test_exception.rb: corresponding tests. * ext/psych/parser.c (parse): Use context_mark for indicating error line and column. * ext/psych/lib/psych/scalar_scanner.rb: use normal begin / rescue since postfix rescue cannot receive the exception class. Thanks nagachika! Added directories: branches/ruby_1_9_3/ext/psych/lib/psych/handlers/ Added files: branches/ruby_1_9_3/ext/psych/lib/psych/handlers/document_stream.rb branches/ruby_1_9_3/ext/psych/lib/psych/syntax_error.rb branches/ruby_1_9_3/test/psych/test_object_references.rb Removed files: branches/ruby_1_9_3/ext/psych/lib/psych/json.rb Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/ext/psych/emitter.c branches/ruby_1_9_3/ext/psych/lib/psych/core_ext.rb branches/ruby_1_9_3/ext/psych/lib/psych/parser.rb branches/ruby_1_9_3/ext/psych/lib/psych/scalar_scanner.rb branches/ruby_1_9_3/ext/psych/lib/psych/tree_builder.rb branches/ruby_1_9_3/ext/psych/lib/psych/visitors/to_ruby.rb branches/ruby_1_9_3/ext/psych/lib/psych/visitors/yaml_tree.rb branches/ruby_1_9_3/ext/psych/lib/psych.rb branches/ruby_1_9_3/ext/psych/parser.c branches/ruby_1_9_3/test/psych/test_array.rb branches/ruby_1_9_3/test/psych/test_encoding.rb branches/ruby_1_9_3/test/psych/test_exception.rb branches/ruby_1_9_3/test/psych/test_merge_keys.rb branches/ruby_1_9_3/test/psych/test_numeric.rb branches/ruby_1_9_3/test/psych/test_parser.rb branches/ruby_1_9_3/test/psych/test_scalar_scanner.rb branches/ruby_1_9_3/test/psych/test_stream.rb branches/ruby_1_9_3/test/psych/test_string.rb branches/ruby_1_9_3/test/psych/test_tainted.rb branches/ruby_1_9_3/version.h Index: ruby_1_9_3/ChangeLog =================================================================== --- ruby_1_9_3/ChangeLog (revision 35164) +++ ruby_1_9_3/ChangeLog (revision 35165) @@ -1,3 +1,161 @@ +Wed Mar 28 08:44:24 2012 Aaron Patterson <aaron@t...> + + * ext/psych/lib/psych.rb: updating version to match gem + * ext/psych/psych.gemspec: ditto + * ext/psych/lib/psych/visitors/to_ruby.rb: fixing deprecation warning + +Mon Jul 18 13:36:47 2011 Aaron Patterson <aaron@t...> + + * ext/psych/lib/psych.rb: define a new BadAlias error class. + + * ext/psych/lib/psych/visitors/to_ruby.rb: raise an exception when + deserializing an alias that does not exist. + + * test/psych/test_merge_keys.rb: corresponding test. + +Fri Mar 9 06:29:22 2012 Aaron Patterson <aaron@t...> + + * ext/psych/lib/psych.rb (load, parse): stop parsing or loading after + the first document has been parsed. + + * test/psych/test_stream.rb: pertinent tests. + +Fri Mar 9 06:17:05 2012 Aaron Patterson <aaron@t...> + + * ext/psych/lib/psych.rb (parse_stream, load_stream): if a block is + given, documents will be yielded to the block as they are parsed. + [ruby-core:42404] [Bug #5978] + + * ext/psych/lib/psych/handlers/document_stream.rb: add a handler that + yields documents as they are parsed + + * test/psych/test_stream.rb: corresponding tests. + +Tue Mar 6 02:31:20 2012 Aaron Patterson <aaron@t...> + + * ext/psych/lib/psych/core_ext.rb: only extend Kernel if IRB is loaded + in order to stop method pollution. + +Tue Feb 28 10:28:51 2012 Aaron Patterson <aaron@t...> + + * ext/psych/lib/psych.rb: default open YAML files with utf8 external + encoding. [ruby-core:42967] + * test/psych/test_tainted.rb: ditto + +Fri Feb 24 13:54:33 2012 Aaron Patterson <aaron@t...> + + * ext/psych/parser.c: prevent a memory leak by protecting calls to + handler callbacks. + * test/psych/test_parser.rb: test to demonstrate leak. + +Fri Feb 24 08:08:38 2012 Aaron Patterson <aaron@t...> + + * ext/psych/parser.c: set parser encoding based on the YAML input + rather than user configuration. + * test/psych/test_encoding.rb: corresponding tests. + * test/psych/test_parser.rb: ditto + * test/psych/test_tainted.rb: ditto + +Fri Feb 10 03:41:31 2012 Aaron Patterson <aaron@t...> + + * ext/psych/parser.c: removed external encoding setter, allow parser + to be reused. + * ext/psych/lib/psych/parser.rb: added external encoding setter. + * test/psych/test_parser.rb: test parser reuse + +Wed Jan 18 12:49:15 2012 Aaron Patterson <aaron@t...> + + * ext/psych/lib/psych/visitors/to_ruby.rb: Added support for loading + subclasses of String with ivars + * ext/psych/lib/psych/visitors/yaml_tree.rb: Added support for dumping + subclasses of String with ivars + * test/psych/test_string.rb: corresponding tests + +Wed Jan 18 10:39:47 2012 Aaron Patterson <aaron@t...> + + * ext/psych/lib/psych/visitors/to_ruby.rb: Added ability to load array + subclasses with ivars. + * ext/psych/lib/psych/visitors/yaml_tree.rb: Added ability to dump + array subclasses with ivars. + * test/psych/test_array.rb: corresponding tests + +Wed Dec 21 02:25:36 2011 Aaron Patterson <aaron@t...> + + * ext/psych/emitter.c: fixing clang warnings. Thanks Joey! + +Sun Dec 18 12:42:48 2011 Aaron Patterson <aaron@t...> + + * ext/psych/lib/psych/visitors/to_ruby.rb: BigDecimals can be restored + from YAML. + * ext/psych/lib/psych/visitors/yaml_tree.rb: BigDecimals can be dumped + to YAML. + * test/psych/test_numeric.rb: tests for BigDecimal serialization + +Sun Dec 18 12:03:13 2011 Aaron Patterson <aaron@t...> + + * ext/psych/lib/psych/scalar_scanner.rb: Strings that look like dates + should be treated as strings and not dates. + + * test/psych/test_scalar_scanner.rb: corresponding tests. + +Wed Dec 7 08:04:31 2011 Aaron Patterson <aaron@t...> + + * ext/psych/lib/psych.rb (module Psych): parse and load methods take + an optional file name that is used when raising Psych::SyntaxError + exceptions + * ext/psych/lib/psych/syntax_error.rb (module Psych): allow nil file + names and handle nil file names in the exception message + * test/psych/test_exception.rb (module Psych): Tests for changes. + +Wed Nov 30 09:09:37 2011 Aaron Patterson <aaron@t...> + + * ext/psych/parser.c (parse): parse method can take an option file + name for use in exception messages. + * test/psych/test_parser.rb: corresponding tests. + +Tue Nov 22 04:46:22 2011 Aaron Patterson <aaron@t...> + + * ext/psych/lib/psych.rb: remove autoload from psych + * ext/psych/lib/psych/json.rb: ditto + +Wed Nov 9 04:52:16 2011 Aaron Patterson <aaron@t...> + + * ext/psych/lib/psych/tree_builder.rb: dump complex numbers, + rationals, etc with reference ids. + * ext/psych/lib/psych/visitors/yaml_tree.rb: ditto + * ext/psych/lib/psych/visitors/to_ruby.rb: loading complex numbers, + rationals, etc with reference ids. + * test/psych/test_object_references.rb: corresponding tests + +Mon Nov 7 20:31:52 2011 Aaron Patterson <aaron@t...> + + * ext/psych/lib/psych/scalar_scanner.rb: make sure strings that look + like base 60 numbers are serialized as quoted strings. + * test/psych/test_string.rb: test for change. + +Thu Oct 27 08:47:38 2011 Martin Bosslet <Martin.Bosslet@g...> + + * ext/psych/parser.c: remove unused variable. + +Wed Oct 5 02:50:27 2011 Aaron Patterson <aaron@t...> + + * ext/psych/lib/psych/syntax_error.rb: Add file, line, offset, and + message attributes during parse failure. + * ext/psych/parser.c: Update parser to raise exception with correct + values. + * test/psych/test_exception.rb: corresponding tests. + +Wed Oct 5 01:52:16 2011 Aaron Patterson <aaron@t...> + + * ext/psych/parser.c (parse): Use context_mark for indicating error + line and column. + +Wed Oct 5 01:22:08 2011 Aaron Patterson <aaron@t...> + + * ext/psych/lib/psych/scalar_scanner.rb: use normal begin / rescue + since postfix rescue cannot receive the exception class. Thanks + nagachika! + Tue Mar 27 22:22:50 2012 Nobuyoshi Nakada <nobu@r...> * configure.in (RUBY_STACK_GROW_DIRECTION): substitute CPU name as Index: ruby_1_9_3/ext/psych/lib/psych/json.rb =================================================================== --- ruby_1_9_3/ext/psych/lib/psych/json.rb (revision 35164) +++ ruby_1_9_3/ext/psych/lib/psych/json.rb (revision 35165) @@ -1,6 +0,0 @@ -module Psych - module JSON - autoload :TreeBuilder, 'psych/json/tree_builder' - autoload :Stream, 'psych/json/stream' - end -end Index: ruby_1_9_3/ext/psych/lib/psych/scalar_scanner.rb =================================================================== --- ruby_1_9_3/ext/psych/lib/psych/scalar_scanner.rb (revision 35164) +++ ruby_1_9_3/ext/psych/lib/psych/scalar_scanner.rb (revision 35165) @@ -46,9 +46,13 @@ end when TIME parse_time string - when /^\d{4}-\d{1,2}-\d{1,2}$/ + when /^\d{4}-(?:1[012]|0\d|\d)-(?:[12]\d|3[01]|0\d|\d)$/ require 'date' - Date.strptime(string, '%Y-%m-%d') + begin + Date.strptime(string, '%Y-%m-%d') + rescue ArgumentError + string + end when /^\.inf$/i 1 / 0.0 when /^-\.inf$/i @@ -61,7 +65,7 @@ else string.sub(/^:/, '').to_sym end - when /^[-+]?[1-9][0-9_]*(:[0-5]?[0-9])+$/ + when /^[-+]?[0-9][0-9_]*(:[0-5]?[0-9])+$/ i = 0 string.split(':').each_with_index do |n,e| i += (n.to_i * 60 ** (e - 2).abs) @@ -74,13 +78,19 @@ end i when FLOAT - return Float(string.gsub(/[,_]/, '')) rescue ArgumentError + begin + return Float(string.gsub(/[,_]/, '')) + rescue ArgumentError + end @string_cache[string] = true string else if string.count('.') < 2 - return Integer(string.gsub(/[,_]/, '')) rescue ArgumentError + begin + return Integer(string.gsub(/[,_]/, '')) + rescue ArgumentError + end end @string_cache[string] = true Index: ruby_1_9_3/ext/psych/lib/psych/visitors/yaml_tree.rb =================================================================== --- ruby_1_9_3/ext/psych/lib/psych/visitors/yaml_tree.rb (revision 35164) +++ ruby_1_9_3/ext/psych/lib/psych/visitors/yaml_tree.rb (revision 35165) @@ -159,13 +159,13 @@ end def visit_Regexp o - @emitter.scalar o.inspect, nil, '!ruby/regexp', false, false, Nodes::Scalar::ANY + register o, @emitter.scalar(o.inspect, nil, '!ruby/regexp', false, false, Nodes::Scalar::ANY) end def visit_DateTime o formatted = format_time o.to_time tag = '!ruby/object:DateTime' - @emitter.scalar formatted, nil, tag, false, false, Nodes::Scalar::ANY + register o, @emitter.scalar(formatted, nil, tag, false, false, Nodes::Scalar::ANY) end def visit_Time o @@ -174,7 +174,7 @@ end def visit_Rational o - @emitter.start_mapping(nil, '!ruby/object:Rational', false, Nodes::Mapping::BLOCK) + register o, @emitter.start_mapping(nil, '!ruby/object:Rational', false, Nodes::Mapping::BLOCK) [ 'denominator', o.denominator.to_s, @@ -187,7 +187,7 @@ end def visit_Complex o - @emitter.start_mapping(nil, '!ruby/object:Complex', false, Nodes::Mapping::BLOCK) + register o, @emitter.start_mapping(nil, '!ruby/object:Complex', false, Nodes::Mapping::BLOCK) ['real', o.real.to_s, 'image', o.imag.to_s].each do |m| @emitter.scalar m, nil, nil, true, false, Nodes::Scalar::ANY @@ -214,6 +214,10 @@ end end + def visit_BigDecimal o + @emitter.scalar o._dump, nil, '!ruby/object:BigDecimal', false, false, Nodes::Scalar::ANY + end + def binary? string string.encoding == Encoding::ASCII_8BIT || string.index("\x00") || @@ -241,9 +245,15 @@ ivars = find_ivars o if ivars.empty? + unless o.class == ::String + tag = "!ruby/string:#{o.class}" + end @emitter.scalar str, nil, tag, plain, quote, style else - @emitter.start_mapping nil, '!str', false, Nodes::Mapping::BLOCK + maptag = '!ruby/string' + maptag << ":#{o.class}" unless o.class == ::String + + @emitter.start_mapping nil, maptag, false, Nodes::Mapping::BLOCK @emitter.scalar 'str', nil, nil, true, false, Nodes::Scalar::ANY @emitter.scalar str, nil, tag, plain, quote, style @@ -255,16 +265,16 @@ def visit_Module o raise TypeError, "can't dump anonymous module: #{o}" unless o.name - @emitter.scalar o.name, nil, '!ruby/module', false, false, Nodes::Scalar::SINGLE_QUOTED + register o, @emitter.scalar(o.name, nil, '!ruby/module', false, false, Nodes::Scalar::SINGLE_QUOTED) end def visit_Class o raise TypeError, "can't dump anonymous class: #{o}" unless o.name - @emitter.scalar o.name, nil, '!ruby/class', false, false, Nodes::Scalar::SINGLE_QUOTED + register o, @emitter.scalar(o.name, nil, '!ruby/class', false, false, Nodes::Scalar::SINGLE_QUOTED) end def visit_Range o - @emitter.start_mapping nil, '!ruby/range', false, Nodes::Mapping::BLOCK + register o, @emitter.start_mapping(nil, '!ruby/range', false, Nodes::Mapping::BLOCK) ['begin', o.begin, 'end', o.end, 'excl', o.exclude_end?].each do |m| accept m end @@ -297,9 +307,13 @@ end def visit_Array o - register o, @emitter.start_sequence(nil, nil, true, Nodes::Sequence::BLOCK) - o.each { |c| accept c } - @emitter.end_sequence + if o.class == ::Array + register o, @emitter.start_sequence(nil, nil, true, Nodes::Sequence::BLOCK) + o.each { |c| accept c } + @emitter.end_sequence + else + visit_array_subclass o + end end def visit_NilClass o @@ -311,6 +325,39 @@ end private + def visit_array_subclass o + tag = "!ruby/array:#{o.class}" + if o.instance_variables.empty? + node = @emitter.start_sequence(nil, tag, false, Nodes::Sequence::BLOCK) + register o, node + o.each { |c| accept c } + @emitter.end_sequence + else + node = @emitter.start_mapping(nil, tag, false, Nodes::Sequence::BLOCK) + register o, node + + # Dump the internal list + accept 'internal' + @emitter.start_sequence(nil, nil, true, Nodes::Sequence::BLOCK) + o.each { |c| accept c } + @emitter.end_sequence + + # Dump the ivars + accept 'ivars' + @emitter.start_mapping(nil, nil, true, Nodes::Sequence::BLOCK) + o.instance_variables.each do |ivar| + accept ivar + accept o.instance_variable_get ivar + end + @emitter.end_mapping + + @emitter.end_mapping + end + end + + def dump_list o + end + # '%:z' was no defined until 1.9.3 if RUBY_VERSION < '1.9.3' def format_time time Index: ruby_1_9_3/ext/psych/lib/psych/visitors/to_ruby.rb =================================================================== --- ruby_1_9_3/ext/psych/lib/psych/visitors/to_ruby.rb (revision 35164) +++ ruby_1_9_3/ext/psych/lib/psych/visitors/to_ruby.rb (revision 35165) @@ -31,9 +31,7 @@ result end - def visit_Psych_Nodes_Scalar o - @st[o.anchor] = o.value if o.anchor - + def deserialize o if klass = Psych.load_tags[o.tag] instance = klass.allocate @@ -52,8 +50,16 @@ case o.tag when '!binary', 'tag:yaml.org,2002:binary' o.value.unpack('m').first - when '!str', 'tag:yaml.org,2002:str' - o.value + when /^!(?:str|ruby\/string)(?::(.*))?/, 'tag:yaml.org,2002:str' + klass = resolve_class($1) + if klass + klass.allocate.replace o.value + else + o.value + end + when '!ruby/object:BigDecimal' + require 'bigdecimal' + BigDecimal._load o.value when "!ruby/object:DateTime" require 'date' @ss.parse_time(o.value).to_datetime @@ -92,7 +98,12 @@ @ss.tokenize o.value end end + private :deserialize + def visit_Psych_Nodes_Scalar o + register o, deserialize(o) + end + def visit_Psych_Nodes_Sequence o if klass = Psych.load_tags[o.tag] instance = klass.allocate @@ -108,15 +119,18 @@ case o.tag when '!omap', 'tag:yaml.org,2002:omap' - map = Psych::Omap.new - @st[o.anchor] = map if o.anchor + map = register(o, Psych::Omap.new) o.children.each { |a| map[accept(a.children.first)] = accept a.children.last } map + when /^!(?:seq|ruby\/array):(.*)$/ + klass = resolve_class($1) + list = register(o, klass.allocate) + o.children.each { |c| list.push accept c } + list else - list = [] - @st[o.anchor] = list if o.anchor + list = register(o, []) o.children.each { |c| list.push accept c } list end @@ -127,16 +141,33 @@ return revive_hash({}, o) unless o.tag case o.tag - when '!str', 'tag:yaml.org,2002:str' + when /^!(?:str|ruby\/string)(?::(.*))?/, 'tag:yaml.org,2002:str' + klass = resolve_class($1) members = Hash[*o.children.map { |c| accept c }] string = members.delete 'str' + + if klass + string = klass.allocate + string.replace string + end + init_with(string, members.map { |k,v| [k.to_s.sub(/^@/, ''),v] }, o) + when /^!ruby\/array:(.*)$/ + klass = resolve_class($1) + list = register(o, klass.allocate) + + members = Hash[o.children.map { |c| accept c }.each_slice(2).to_a] + list.replace members['internal'] + + members['ivars'].each do |ivar, v| + list.instance_variable_set ivar, v + end + list when /^!ruby\/struct:?(.*)?$/ klass = resolve_class($1) if klass - s = klass.allocate - @st[o.anchor] = s if o.anchor + s = register(o, klass.allocate) members = {} struct_members = s.members.map { |x| x.to_sym } @@ -158,7 +189,7 @@ when '!ruby/range' h = Hash[*o.children.map { |c| accept c }] - Range.new(h['begin'], h['end'], h['excl']) + register o, Range.new(h['begin'], h['end'], h['excl']) when /^!ruby\/exception:?(.*)?$/ h = Hash[*o.children.map { |c| accept c }] @@ -177,11 +208,11 @@ when '!ruby/object:Complex' h = Hash[*o.children.map { |c| accept c }] - Complex(h['real'], h['image']) + register o, Complex(h['real'], h['image']) when '!ruby/object:Rational' h = Hash[*o.children.map { |c| accept c }] - Rational(h['numerator'], h['denominator']) + register o, Rational(h['numerator'], h['denominator']) when /^!ruby\/object:?(.*)?$/ name = $1 || 'Object' @@ -205,10 +236,15 @@ end def visit_Psych_Nodes_Alias o - @st[o.anchor] + @st.fetch(o.anchor) { raise BadAlias, "Unknown alias: #{o.anchor}" } end private + def register node, object + @st[node.anchor] = object if node.anchor + object + end + def revive_hash hash, o @st[o.anchor] = hash if o.anchor @@ -249,7 +285,7 @@ o.init_with c elsif o.respond_to?(:yaml_initialize) if $VERBOSE - "Implementing #{o.class}#yaml_initialize is deprecated, please implement \"init_with(coder)\"" + warn "Implementing #{o.class}#yaml_initialize is deprecated, please implement \"init_with(coder)\"" end o.yaml_initialize c.tag, c.map else Index: ruby_1_9_3/ext/psych/lib/psych/parser.rb =================================================================== --- ruby_1_9_3/ext/psych/lib/psych/parser.rb (revision 35164) +++ ruby_1_9_3/ext/psych/lib/psych/parser.rb (revision 35165) @@ -36,12 +36,16 @@ # The handler on which events will be called attr_accessor :handler + # Set the encoding for this parser to +encoding+ + attr_writer :external_encoding + ### # Creates a new Psych::Parser instance with +handler+. YAML events will # be called on +handler+. See Psych::Parser for more details. def initialize handler = Handler.new @handler = handler + @external_encoding = ANY end end end Index: ruby_1_9_3/ext/psych/lib/psych/handlers/document_stream.rb =================================================================== --- ruby_1_9_3/ext/psych/lib/psych/handlers/document_stream.rb (revision 0) +++ ruby_1_9_3/ext/psych/lib/psych/handlers/document_stream.rb (revision 35165) @@ -0,0 +1,22 @@ +require 'psych/tree_builder' + +module Psych + module Handlers + class DocumentStream < Psych::TreeBuilder # :nodoc: + def initialize &block + super + @block = block + end + + def start_document version, tag_directives, implicit + n = Nodes::Document.new version, tag_directives, implicit + (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/