From c7e69a61daf7ee3cfcddeb7ee19c39fe05529556 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Wed, 29 Jan 2020 08:32:08 +0900 Subject: [PATCH] Fix taint warnings on Ruby master `$VERBOSE = false` won't be worked since `rb_warning` is changed to `rb_warn`. Ref https://github.com/ruby/ruby/pull/2856. --- lib/tzinfo.rb | 10 +++------- test/tzinfo-data2/tzinfo/data.rb | 8 ++------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/lib/tzinfo.rb b/lib/tzinfo.rb index 42121b57..1537a929 100644 --- a/lib/tzinfo.rb +++ b/lib/tzinfo.rb @@ -8,13 +8,9 @@ module TZInfo # 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 # 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 +o = Object.new +if [:taint, :untaint, :tainted?].none? {|m| o.respond_to?(m) } || RUBY_VERSION >= '2.7' + require_relative 'tzinfo/untaint_ext' end require_relative 'tzinfo/version' diff --git a/test/tzinfo-data2/tzinfo/data.rb b/test/tzinfo-data2/tzinfo/data.rb index 4c7bb326..bd8f6d33 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 < '2.7' + location.untaint end # The directory containing the TZInfo::Data files.