diff --git a/lib/tzinfo/ruby_core_support.rb b/lib/tzinfo/ruby_core_support.rb index 5d8e219d..9b56893c 100644 --- a/lib/tzinfo/ruby_core_support.rb +++ b/lib/tzinfo/ruby_core_support.rb @@ -156,21 +156,15 @@ def self.open_file(file_name, mode, opts, &block) # 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 - if [:taint, :untaint, :tainted?].none? {|m| o.respond_to?(m) } || !o.taint.tainted? - module UntaintExt - refine Object do - def untaint - self - end + o = Object.new + if [:taint, :untaint, :tainted?].none? {|m| o.respond_to?(m) } || RUBY_VERSION >= '2.7' + module UntaintExt + refine Object do + def untaint + self end end end - ensure - $VERBOSE = old_verbose end end end