ruby-changes:62591
From: Jeremy <ko1@a...>
Date: Sun, 16 Aug 2020 23:42:03 +0900 (JST)
Subject: [ruby-changes:62591] a73b5cc556 (master): Remove the deprecated override of Kernel#open in open-uri
https://git.ruby-lang.org/ruby.git/commit/?id=a73b5cc556 From a73b5cc556bd131fe924ed6bb02b3c5bdf1593e8 Mon Sep 17 00:00:00 2001 From: Jeremy Evans <code@j...> Date: Thu, 30 Jul 2020 12:48:19 -0700 Subject: Remove the deprecated override of Kernel#open in open-uri This was deprecated in 2.7 to resolve [Misc #15893]. diff --git a/lib/open-uri.rb b/lib/open-uri.rb index dd68ea7..421a82e 100644 --- a/lib/open-uri.rb +++ b/lib/open-uri.rb @@ -3,27 +3,6 @@ require 'uri' https://github.com/ruby/ruby/blob/trunk/lib/open-uri.rb#L3 require 'stringio' require 'time' -module Kernel - private - alias open_uri_original_open open # :nodoc: - class << self - alias open_uri_original_open open # :nodoc: - end - - def open(name, *rest, **kw, &block) # :nodoc: - if (name.respond_to?(:open) && !name.respond_to?(:to_path)) || - (name.respond_to?(:to_str) && - %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://} =~ name && - (uri = URI.parse(name)).respond_to?(:open)) - warn('calling URI.open via Kernel#open is deprecated, call URI.open directly or use URI#open', uplevel: 1) - URI.open(name, *rest, **kw, &block) - else - open_uri_original_open(name, *rest, **kw, &block) - end - end - module_function :open -end - module URI # Allows the opening of various resources including URIs. # @@ -49,9 +28,7 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/open-uri.rb#L28 (uri = URI.parse(name)).respond_to?(:open) uri.open(*rest, &block) else - open_uri_original_open(name, *rest, &block) - # After Kernel#open override is removed: - #super + super end end end diff --git a/test/open-uri/test_open-uri.rb b/test/open-uri/test_open-uri.rb index 0c7d77c..9a52e7a 100644 --- a/test/open-uri/test_open-uri.rb +++ b/test/open-uri/test_open-uri.rb @@ -68,18 +68,6 @@ class TestOpenURI < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/open-uri/test_open-uri.rb#L68 @proxies.each_with_index {|k, i| ENV[k] = @old_proxies[i] } end - def test_deprecated_kernel_open - with_http {|srv, dr, url| - srv.mount_proc("/foo200", lambda { |req, res| res.body = "foo200" } ) - assert_warning(/calling URI.open via Kernel#open is deprecated, call URI.open directly/) { - open("#{url}/foo200") {|f| - assert_equal("200", f.status[0]) - assert_equal("foo200", f.read) - } - } - } - end - def test_200_uri_open with_http {|srv, dr, url| srv.mount_proc("/urifoo200", lambda { |req, res| res.body = "urifoo200" } ) -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/