From 81f0c1db6abf4a068ca0ca21f3ed837e32651093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ondruch?= Date: Wed, 20 Jan 2021 15:03:24 +0100 Subject: [PATCH] Fix FTBFS due to Ruby 3.0 update. --- ...NaN-and-Infinity-on-newer-BigDecimal.patch | 34 ++++++++++++++ ...ub-as-an-unsafe-method-on-SafeBuffer.patch | 44 +++++++++++++++++++ ...upportEncoder-to_json-for-Ruby-2.8.0.patch | 33 ++++++++++++++ rubygem-activesupport.spec | 19 +++++++- 4 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 rubygem-activesupport-6.0.3.4-Fix-rounding-NaN-and-Infinity-on-newer-BigDecimal.patch create mode 100644 rubygem-activesupport-6.0.3.4-Mark-scrub-as-an-unsafe-method-on-SafeBuffer.patch create mode 100644 rubygem-activesupport-6.0.3.4-Use-Hash-ActiveSupport-ToJsonWithActiveSupportEncoder-to_json-for-Ruby-2.8.0.patch diff --git a/rubygem-activesupport-6.0.3.4-Fix-rounding-NaN-and-Infinity-on-newer-BigDecimal.patch b/rubygem-activesupport-6.0.3.4-Fix-rounding-NaN-and-Infinity-on-newer-BigDecimal.patch new file mode 100644 index 0000000..0eec3bf --- /dev/null +++ b/rubygem-activesupport-6.0.3.4-Fix-rounding-NaN-and-Infinity-on-newer-BigDecimal.patch @@ -0,0 +1,34 @@ +From 91d852fe2c6a6bf51287a1ad95ef6e21ffa9d261 Mon Sep 17 00:00:00 2001 +From: Eugene Kenny +Date: Fri, 1 Jan 2021 16:05:37 +0000 +Subject: [PATCH] Fix rounding NaN and Infinity on newer BigDecimal + +Since BigDecimal 2.0.3, BigDecimal#round returns an integer if the +requested precision is less than 1: +https://github.com/ruby/bigdecimal/commit/e8fc98050167fd943574609988b8754414e0a7c1 + +NaN and Infinity cannot be represented as an integer, so rounding these +values now raises a FloatDomainError. This is a regression of the fix in +081a3963ea2aab617a92874d7ef59ce98eee6a64. + +Specifying the rounding mode restores the previous behaviour. + +This isn't a problem on master or 6-1-stable, as the rounding mode is +always specified there since 7905bdfd8b2ae50319cd7a9a74ee1f8c865d648d. +--- + .../lib/active_support/number_helper/rounding_helper.rb | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/activesupport/lib/active_support/number_helper/rounding_helper.rb b/activesupport/lib/active_support/number_helper/rounding_helper.rb +index 2ad8d49c4edb..7f7242f8651a 100644 +--- a/activesupport/lib/active_support/number_helper/rounding_helper.rb ++++ b/activesupport/lib/active_support/number_helper/rounding_helper.rb +@@ -26,7 +26,7 @@ def digit_count(number) + + private + def round_without_significant(number) +- number = number.round(precision) ++ number = number.round(precision, BigDecimal.mode(BigDecimal::ROUND_MODE)) + number = number.to_i if precision == 0 && number.finite? + number = number.abs if number.zero? # prevent showing negative zeros + number diff --git a/rubygem-activesupport-6.0.3.4-Mark-scrub-as-an-unsafe-method-on-SafeBuffer.patch b/rubygem-activesupport-6.0.3.4-Mark-scrub-as-an-unsafe-method-on-SafeBuffer.patch new file mode 100644 index 0000000..6a2c7f3 --- /dev/null +++ b/rubygem-activesupport-6.0.3.4-Mark-scrub-as-an-unsafe-method-on-SafeBuffer.patch @@ -0,0 +1,44 @@ +From a4d2493b26ff166aa3605684f22e0abb174c0752 Mon Sep 17 00:00:00 2001 +From: Akira Matsuda +Date: Sat, 21 Nov 2020 09:54:43 +0900 +Subject: [PATCH] Let AS::SafeBuffer#[] and * return value be an instance of + SafeBuffer in Ruby 3 + +Ruby 3 introduces an incompatibility that String methods return String instances when called on a subclass instance. +https://bugs.ruby-lang.org/issues/10845 +https://github.com/ruby/ruby/pull/3701 +--- + .../active_support/core_ext/string/output_safety.rb | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb +index 635f9cf45780..60e39d58ca5c 100644 +--- a/activesupport/lib/active_support/core_ext/string/output_safety.rb ++++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb +@@ -153,12 +153,12 @@ def initialize + + def [](*args) + if html_safe? +- new_safe_buffer = super ++ new_string = super + +- if new_safe_buffer +- new_safe_buffer.instance_variable_set :@html_safe, true +- end ++ return unless new_string + ++ new_safe_buffer = new_string.is_a?(SafeBuffer) ? new_string : SafeBuffer.new(new_string) ++ new_safe_buffer.instance_variable_set :@html_safe, true + new_safe_buffer + else + to_str[*args] +@@ -214,7 +214,8 @@ def +(other) + end + + def *(*) +- new_safe_buffer = super ++ new_string = super ++ new_safe_buffer = new_string.is_a?(SafeBuffer) ? new_string : SafeBuffer.new(new_string) + new_safe_buffer.instance_variable_set(:@html_safe, @html_safe) + new_safe_buffer + end diff --git a/rubygem-activesupport-6.0.3.4-Use-Hash-ActiveSupport-ToJsonWithActiveSupportEncoder-to_json-for-Ruby-2.8.0.patch b/rubygem-activesupport-6.0.3.4-Use-Hash-ActiveSupport-ToJsonWithActiveSupportEncoder-to_json-for-Ruby-2.8.0.patch new file mode 100644 index 0000000..79416ea --- /dev/null +++ b/rubygem-activesupport-6.0.3.4-Use-Hash-ActiveSupport-ToJsonWithActiveSupportEncoder-to_json-for-Ruby-2.8.0.patch @@ -0,0 +1,33 @@ +From fdbc55b9d55ae9d2b5b39be3ef4af5f60f6954a3 Mon Sep 17 00:00:00 2001 +From: Yasuo Honda +Date: Mon, 22 Jun 2020 21:19:21 +0900 +Subject: [PATCH] Use + Array(ActiveSupport::ToJsonWithActiveSupportEncoder)#to_json and + Hash(ActiveSupport::ToJsonWithActiveSupportEncoder)#to_json for Ruby 2.8.0 + +This pull request addresses failures at https://buildkite.com/rails/rails/builds/70219#79d96882-6c51-4854-8cab-28f50ac8bca1 +According to https://bugs.ruby-lang.org/issues/16973 This is an expected change in Ruby. +These failures has been addressed by changing the order of prepend as suggested. + +Refer +https://github.com/ruby/ruby/pull/3181 +https://github.com/ruby/ruby/pull/2936 +https://bugs.ruby-lang.org/issues/9573 +https://github.com/rails/rails/pull/19413 +--- + activesupport/lib/active_support/core_ext/object/json.rb | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/activesupport/lib/active_support/core_ext/object/json.rb b/activesupport/lib/active_support/core_ext/object/json.rb +index d92af19137cd..dcfbe8b40f2a 100644 +--- a/activesupport/lib/active_support/core_ext/object/json.rb ++++ b/activesupport/lib/active_support/core_ext/object/json.rb +@@ -45,7 +45,7 @@ def to_json(options = nil) + end + end + +-[Object, Array, FalseClass, Float, Hash, Integer, NilClass, String, TrueClass, Enumerable].reverse_each do |klass| ++[Enumerable, Object, Array, FalseClass, Float, Hash, Integer, NilClass, String, TrueClass].reverse_each do |klass| + klass.prepend(ActiveSupport::ToJsonWithActiveSupportEncoder) + end + diff --git a/rubygem-activesupport.spec b/rubygem-activesupport.spec index 74e8ccc..8820fd5 100644 --- a/rubygem-activesupport.spec +++ b/rubygem-activesupport.spec @@ -5,7 +5,7 @@ Name: rubygem-%{gem_name} Epoch: 1 Version: 6.0.3.4 -Release: 1%{?dist} +Release: 2%{?dist} Summary: A support libraries and Ruby core extensions extracted from the Rails framework License: MIT URL: http://rubyonrails.org @@ -32,6 +32,16 @@ Patch3: rubygem-activesupport-6.0.4-Reduce-FILENAME_MAX_SIZE-to-accomodate-large # https://github.com/rails/rails/pull/40198 Patch4: rubygem-activesupport-6.1.0-Anchor-BacktraceCleaner-gem-filter-regexp.patch Patch5: rubygem-activesupport-6.1.0-Anchor-BacktraceCleaner-gem-filter-regexp-test.patch +# Fix `ActiveSupport::NumberHelper::NumberHelperTest#test_number_to_percentage` +# test failure. +# https://github.com/rails/rails/commit/91d852fe2c6a6bf51287a1ad95ef6e21ffa9d261 +Patch6: rubygem-activesupport-6.0.3.4-Fix-rounding-NaN-and-Infinity-on-newer-BigDecimal.patch +# Fix `SafeBuffer` test failures. +# https://github.com/rails/rails/pull/40663 +Patch7: rubygem-activesupport-6.0.3.4-Mark-scrub-as-an-unsafe-method-on-SafeBuffer.patch +# Fix test/json/encoding_test.rb test failures. +# https://github.com/rails/rails/pull/39697 +Patch8: rubygem-activesupport-6.0.3.4-Use-Hash-ActiveSupport-ToJsonWithActiveSupportEncoder-to_json-for-Ruby-2.8.0.patch # ruby package has just soft dependency on rubygem({bigdecimal,json}), while # ActiveSupport always requires them. @@ -53,6 +63,7 @@ BuildRequires: rubygem(rack) BuildRequires: rubygem(tzinfo) >= 1.1 BuildRequires: rubygem(listen) BuildRequires: rubygem(redis) +BuildRequires: rubygem(rexml) BuildRequires: memcached BuildArch: noarch @@ -76,6 +87,9 @@ Documentation for %{name}. %patch1 -p2 %patch3 -p2 %patch4 -p2 +%patch6 -p2 +%patch7 -p2 +%patch8 -p2 pushd %{_builddir} %patch2 -p2 @@ -137,6 +151,9 @@ popd %doc %{gem_instdir}/README.rdoc %changelog +* Wed Jan 20 2021 Vít Ondruch - 1:6.0.3.4-2 +- Fix FTBFS due to Ruby 3.0 update. + * Thu Oct 8 10:45:37 CEST 2020 Pavel Valena - 1:6.0.3.4-1 - Update to activesupport 6.0.3.4. Resolves: rhbz#1886136