[前][次][番号順一覧][スレッド一覧]

ruby-changes:69861

From: Hiroshi <ko1@a...>
Date: Mon, 22 Nov 2021 10:52:14 +0900 (JST)
Subject: [ruby-changes:69861] 5afefe4371 (ruby_3_0): Bump psych version to 3.3.2

https://git.ruby-lang.org/ruby.git/commit/?id=5afefe4371

From 5afefe4371b19155fc4d692a5ff2616ad748e9cc Mon Sep 17 00:00:00 2001
From: Hiroshi SHIBATA <hsbt@r...>
Date: Thu, 11 Nov 2021 20:39:22 +0900
Subject: Bump psych version to 3.3.2

---
 ext/psych/lib/psych.rb                    |   8 +-
 ext/psych/lib/psych/handler.rb            |   2 +-
 ext/psych/lib/psych/nodes/scalar.rb       |   2 +-
 ext/psych/lib/psych/versions.rb           |   6 +-
 ext/psych/lib/psych/visitors/to_ruby.rb   |  16 ++--
 ext/psych/lib/psych/visitors/visitor.rb   |   2 +-
 ext/psych/lib/psych/visitors/yaml_tree.rb |   4 +-
 ext/psych/yaml/loader.c                   |   2 +-
 ext/psych/yaml/scanner.c                  |   4 +-
 ext/psych/yaml/yaml.h                     |   8 +-
 ext/psych/yaml/yaml_private.h             |   2 +-
 test/psych/helper.rb                      |  40 +++++----
 test/psych/test_alias_and_anchor.rb       |  12 +--
 test/psych/test_array.rb                  |   6 +-
 test/psych/test_class.rb                  |   4 +-
 test/psych/test_coder.rb                  | 135 ++++++++++++++++++++++++++++--
 test/psych/test_date_time.rb              |   4 +-
 test/psych/test_deprecated.rb             |   4 +-
 test/psych/test_document.rb               |   2 +-
 test/psych/test_emitter.rb                |  10 +--
 test/psych/test_encoding.rb               |   4 +-
 test/psych/test_exception.rb              |  38 ++++-----
 test/psych/test_hash.rb                   |  18 ++--
 test/psych/test_marshalable.rb            |  12 ++-
 test/psych/test_merge_keys.rb             |  24 +++---
 test/psych/test_object.rb                 |   4 +-
 test/psych/test_object_references.rb      |  12 ++-
 test/psych/test_omap.rb                   |   4 +-
 test/psych/test_parser.rb                 |  16 ++--
 test/psych/test_psych.rb                  |  45 +++++-----
 test/psych/test_ractor.rb                 |   4 +-
 test/psych/test_safe_load.rb              |  28 +++----
 test/psych/test_serialize_subclasses.rb   |   4 +-
 test/psych/test_set.rb                    |   6 +-
 test/psych/test_string.rb                 |  14 ++--
 test/psych/test_struct.rb                 |   6 +-
 test/psych/test_yaml.rb                   |  14 ++--
 test/psych/test_yaml_special_cases.rb     |   6 +-
 test/psych/test_yamlstore.rb              |  47 +++++++----
 test/psych/visitors/test_to_ruby.rb       |   4 +-
 test/psych/visitors/test_yaml_tree.rb     |  12 +--
 41 files changed, 377 insertions(+), 218 deletions(-)

diff --git a/ext/psych/lib/psych.rb b/ext/psych/lib/psych.rb
index cedf0a4ad6f..34d2218549e 100644
--- a/ext/psych/lib/psych.rb
+++ b/ext/psych/lib/psych.rb
@@ -271,7 +271,7 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych.rb#L271
   # YAML documents that are supplied via user input.  Instead, please use the
   # safe_load method.
   #
-  def self.load yaml, legacy_filename = NOT_GIVEN, filename: nil, fallback: false, symbolize_names: false, freeze: false
+  def self.unsafe_load yaml, legacy_filename = NOT_GIVEN, filename: nil, fallback: false, symbolize_names: false, freeze: false
     if legacy_filename != NOT_GIVEN
       warn_with_uplevel 'Passing filename with the 2nd argument of Psych.load is deprecated. Use keyword argument like Psych.load(yaml, filename: ...) instead.', uplevel: 1 if $VERBOSE
       filename = legacy_filename
@@ -281,6 +281,7 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych.rb#L281
     return fallback unless result
     result.to_ruby(symbolize_names: symbolize_names, freeze: freeze)
   end
+  class << self; alias :load :unsafe_load; end
 
   ###
   # Safely load the yaml string in +yaml+.  By default, only the following
@@ -577,11 +578,12 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych.rb#L578
   # NOTE: This method *should not* be used to parse untrusted documents, such as
   # YAML documents that are supplied via user input.  Instead, please use the
   # safe_load_file method.
-  def self.load_file filename, **kwargs
+  def self.unsafe_load_file filename, **kwargs
     File.open(filename, 'r:bom|utf-8') { |f|
-      self.load f, filename: filename, **kwargs
+      self.unsafe_load f, filename: filename, **kwargs
     }
   end
+  class << self; alias :load_file :unsafe_load_file; end
 
   ###
   # Safely loads the document contained in +filename+.  Returns the yaml contained in
diff --git a/ext/psych/lib/psych/handler.rb b/ext/psych/lib/psych/handler.rb
index 8f23e366fa3..ad7249ff77c 100644
--- a/ext/psych/lib/psych/handler.rb
+++ b/ext/psych/lib/psych/handler.rb
@@ -119,7 +119,7 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/handler.rb#L119
     # +tag+ is an associated tag or nil
     # +plain+ is a boolean value
     # +quoted+ is a boolean value
-    # +style+ is an integer idicating the string style
+    # +style+ is an integer indicating the string style
     #
     # See the constants in Psych::Nodes::Scalar for the possible values of
     # +style+
diff --git a/ext/psych/lib/psych/nodes/scalar.rb b/ext/psych/lib/psych/nodes/scalar.rb
index e2616b6a844..5550b616a34 100644
--- a/ext/psych/lib/psych/nodes/scalar.rb
+++ b/ext/psych/lib/psych/nodes/scalar.rb
@@ -50,7 +50,7 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/nodes/scalar.rb#L50
       # +tag+ is an associated tag or nil
       # +plain+ is a boolean value
       # +quoted+ is a boolean value
-      # +style+ is an integer idicating the string style
+      # +style+ is an integer indicating the string style
       #
       # == See Also
       #
diff --git a/ext/psych/lib/psych/versions.rb b/ext/psych/lib/psych/versions.rb
index 488f86e0b44..acb21336c4a 100644
--- a/ext/psych/lib/psych/versions.rb
+++ b/ext/psych/lib/psych/versions.rb
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/versions.rb#L1
-
 # frozen_string_literal: true
+
 module Psych
   # The version of Psych you are using
-  VERSION = '3.3.0'
+  VERSION = '3.3.2'
 
   if RUBY_ENGINE == 'jruby'
-    DEFAULT_SNAKEYAML_VERSION = '1.26'.freeze
+    DEFAULT_SNAKEYAML_VERSION = '1.28'.freeze
   end
 end
diff --git a/ext/psych/lib/psych/visitors/to_ruby.rb b/ext/psych/lib/psych/visitors/to_ruby.rb
index ec80701917a..4de7f80d337 100644
--- a/ext/psych/lib/psych/visitors/to_ruby.rb
+++ b/ext/psych/lib/psych/visitors/to_ruby.rb
@@ -24,6 +24,7 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/visitors/to_ruby.rb#L24
         super()
         @st = {}
         @ss = ss
+        @load_tags = Psych.load_tags
         @domain_types = Psych.domain_types
         @class_loader = class_loader
         @symbolize_names = symbolize_names
@@ -48,7 +49,7 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/visitors/to_ruby.rb#L49
       end
 
       def deserialize o
-        if klass = resolve_class(Psych.load_tags[o.tag])
+        if klass = resolve_class(@load_tags[o.tag])
           instance = klass.allocate
 
           if instance.respond_to?(:init_with)
@@ -128,7 +129,7 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/visitors/to_ruby.rb#L129
       end
 
       def visit_Psych_Nodes_Sequence o
-        if klass = resolve_class(Psych.load_tags[o.tag])
+        if klass = resolve_class(@load_tags[o.tag])
           instance = klass.allocate
 
           if instance.respond_to?(:init_with)
@@ -160,8 +161,8 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/visitors/to_ruby.rb#L161
       end
 
       def visit_Psych_Nodes_Mapping o
-        if Psych.load_tags[o.tag]
-          return revive(resolve_class(Psych.load_tags[o.tag]), o)
+        if @load_tags[o.tag]
+          return revive(resolve_class(@load_tags[o.tag]), o)
         end
         return revive_hash(register(o, {}), o) unless o.tag
 
@@ -326,6 +327,7 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/visitors/to_ruby.rb#L327
       end
 
       private
+
       def register node, object
         @st[node.anchor] = object if node.anchor
         object
@@ -337,7 +339,7 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/visitors/to_ruby.rb#L339
         list
       end
 
-      def revive_hash hash, o
+      def revive_hash hash, o, tagged= false
         o.children.each_slice(2) { |k,v|
           key = accept(k)
           val = accept(v)
@@ -364,7 +366,7 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/visitors/to_ruby.rb#L366
               hash[key] = val
             end
           else
-            if @symbolize_names
+            if !tagged && @symbolize_names && key.is_a?(String)
               key = key.to_sym
             elsif !@freeze
               key = deduplicate(key)
@@ -402,7 +404,7 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/visitors/to_ruby.rb#L404
 
       def revive klass, node
         s = register(node, klass.allocate)
-        init_with(s, revive_hash({}, node), node)
+        init_with(s, revive_hash({}, node, true), node)
       end
 
       def init_with o, h, node
diff --git a/ext/psych/lib/psych/visitors/visitor.rb b/ext/psych/lib/psych/visitors/visitor.rb
index e2585c0c774..21052aa66f1 100644
--- a/ext/psych/lib/psych/visitors/visitor.rb
+++ b/ext/psych/lib/psych/visitors/visitor.rb
@@ -17,7 +17,7 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/visitors/visitor.rb#L17
 
       if defined?(Ractor)
         def dispatch
-          Ractor.current[:Psych_Visitors_Visitor] ||= Visitor.dispatch_cache
+          @dispatch_cache ||= (Ractor.current[:Psych_Visitors_Visitor] ||= Visitor.dispatch_cache)
         end
       else
         DISPATCH = dispatch_cache
diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb
index ac6777aeb5d..bf7c0bb8ca9 100644
--- a/ext/psych/lib/psych/visitors/yaml_tree.rb
+++ b/ext/psych/lib/psych/visito (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]