ruby-changes:63200
From: nagachika <ko1@a...>
Date: Tue, 29 Sep 2020 20:33:28 +0900 (JST)
Subject: [ruby-changes:63200] 665589cbdf (ruby_2_7): merge revision(s) df14c758fc705c49c2aaf4c9276a8f7229438fbf: [Backport #17181]
https://git.ruby-lang.org/ruby.git/commit/?id=665589cbdf From 665589cbdf7bf652067113dd1c0bc49012b990e0 Mon Sep 17 00:00:00 2001 From: nagachika <nagachika@r...> Date: Tue, 29 Sep 2020 20:33:06 +0900 Subject: merge revision(s) df14c758fc705c49c2aaf4c9276a8f7229438fbf: [Backport #17181] Make hash returned by Hash#transform_values not have a default This sets an explicit default of nil. There is probably a better approach of removing the default. Fixes [Bug #17181] diff --git a/hash.c b/hash.c index 4a3f2ff..63b228f 100644 --- a/hash.c +++ b/hash.c @@ -3211,6 +3211,7 @@ rb_hash_transform_values(VALUE hash) https://github.com/ruby/ruby/blob/trunk/hash.c#L3211 RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); result = hash_copy(hash_alloc(rb_cHash), hash); + SET_DEFAULT(result, Qnil); if (!RHASH_EMPTY_P(hash)) { rb_hash_stlike_foreach_with_replace(result, transform_values_foreach_func, transform_values_foreach_replace, result); diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index 738b058..046ea40 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -1673,6 +1673,7 @@ class TestHash < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_hash.rb#L1673 x.default_proc = proc {|h, k| k} y = x.transform_values {|v| v ** 2 } assert_nil(y.default_proc) + assert_nil(y.default) y = x.transform_values.with_index {|v, i| "#{v}.#{i}" } assert_equal(%w(1.0 2.1 3.2), y.values_at(:a, :b, :c)) diff --git a/version.h b/version.h index d0e742b..41e9b8f 100644 --- a/version.h +++ b/version.h @@ -2,11 +2,11 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L2 # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 1 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 128 +#define RUBY_PATCHLEVEL 129 #define RUBY_RELEASE_YEAR 2020 #define RUBY_RELEASE_MONTH 9 -#define RUBY_RELEASE_DAY 20 +#define RUBY_RELEASE_DAY 29 #include "ruby/version.h" -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/