Skip to content

Commit

Permalink
Merge pull request #113.
Browse files Browse the repository at this point in the history
  • Loading branch information
philr committed Mar 7, 2020
2 parents fcabcb6 + f4e9658 commit 1b36bdc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
11 changes: 3 additions & 8 deletions lib/tzinfo.rb
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion lib/tzinfo/untaint_ext.rb
Expand Up @@ -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.
#
Expand Down
2 changes: 1 addition & 1 deletion test/test_utils.rb
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions test/tzinfo-data2/tzinfo/data.rb
Expand Up @@ -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.
Expand Down

0 comments on commit 1b36bdc

Please sign in to comment.