diff --git a/lib/tzinfo.rb b/lib/tzinfo.rb index 42121b57..6949127b 100644 --- a/lib/tzinfo.rb +++ b/lib/tzinfo.rb @@ -6,15 +6,10 @@ module TZInfo end # Object#untaint is a deprecated no-op in Ruby >= 2.7 and will be removed in -# 3.0. Add a refinement to either silence the warning, or supply the method if +# 3.2. Add a refinement to either silence the warning, or supply the method if # needed. -old_verbose = $VERBOSE -$VERBOSE = false -begin - o = Object.new - require_relative 'tzinfo/untaint_ext' if [:taint, :untaint, :tainted?].none? {|m| o.respond_to?(m) } || !o.taint.tainted? -ensure - $VERBOSE = old_verbose +if !Object.new.respond_to?(:untaint) || RUBY_VERSION =~ /\A(\d+)\.(\d+)(?:\.|\z)/ && ($1 == '2' && $2.to_i >= 7 || $1.to_i >= 3) + require_relative 'tzinfo/untaint_ext' end require_relative 'tzinfo/version' diff --git a/lib/tzinfo/untaint_ext.rb b/lib/tzinfo/untaint_ext.rb index ace0f37f..4e8d0c07 100644 --- a/lib/tzinfo/untaint_ext.rb +++ b/lib/tzinfo/untaint_ext.rb @@ -2,7 +2,7 @@ # frozen_string_literal: true module TZInfo - # Object#untaint is deprecated in Ruby >= 2.7 and will be removed in 3.0. + # Object#untaint is deprecated in Ruby >= 2.7 and will be removed in 3.2. # UntaintExt adds a refinement to make Object#untaint a no-op and avoid the # warning. # diff --git a/test/test_utils.rb b/test/test_utils.rb index 427d527a..2792d5ef 100644 --- a/test/test_utils.rb +++ b/test/test_utils.rb @@ -499,7 +499,7 @@ def assert_equal_with_offset_and_class(expected, actual) end # Object#taint is a deprecated no-op in Ruby 2.7 and outputs a warning. It - # will be removed in 3.0. Silence the warning or supply a replacement. + # will be removed in 3.2. Silence the warning or supply a replacement. if TZInfo.const_defined?(:UntaintExt) module TaintExt refine Object do diff --git a/test/tzinfo-data2/tzinfo/data.rb b/test/tzinfo-data2/tzinfo/data.rb index 4c7bb326..ea0d67a8 100644 --- a/test/tzinfo-data2/tzinfo/data.rb +++ b/test/tzinfo-data2/tzinfo/data.rb @@ -6,12 +6,8 @@ module TZInfo module Data location = File.dirname(File.dirname(__FILE__)) - old_verbose = $VERBOSE - $VERBOSE = false - begin - location.untaint if location.respond_to?(:untaint) - ensure - $VERBOSE = old_verbose + if location.respond_to?(:untaint) && RUBY_VERSION =~ /\A(\d+)\.(\d+)(?:\.|\z)/ && ($1 == '2' && $2.to_i < 7 || $1.to_i <= 1) + location.untaint end # The directory containing the TZInfo::Data files.