[前][次][番号順一覧][スレッド一覧]

ruby-changes:65933

From: Jeremy <ko1@a...>
Date: Thu, 22 Apr 2021 14:57:33 +0900 (JST)
Subject: [ruby-changes:65933] 10ad81eb2d (master): [ruby/uri] Only use UnboundMethod#bind_call if it is available

https://git.ruby-lang.org/ruby.git/commit/?id=10ad81eb2d

From 10ad81eb2d4bf44b5d5350e3ea28e6248f550128 Mon Sep 17 00:00:00 2001
From: Jeremy Evans <code@j...>
Date: Thu, 4 Mar 2021 15:19:25 -0800
Subject: [ruby/uri] Only use UnboundMethod#bind_call if it is available

This allows tests to pass on Ruby 2.4-2.6.

Fixes #19

https://github.com/ruby/uri/commit/67ca99ca87
---
 lib/uri/rfc2396_parser.rb | 10 ++++++++--
 lib/uri/rfc3986_parser.rb | 10 ++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/lib/uri/rfc2396_parser.rb b/lib/uri/rfc2396_parser.rb
index 1c9ce17..76a8f99 100644
--- a/lib/uri/rfc2396_parser.rb
+++ b/lib/uri/rfc2396_parser.rb
@@ -322,8 +322,14 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/uri/rfc2396_parser.rb#L322
     end
 
     @@to_s = Kernel.instance_method(:to_s)
-    def inspect
-      @@to_s.bind_call(self)
+    if @@to_s.respond_to?(:bind_call)
+      def inspect
+        @@to_s.bind_call(self)
+      end
+    else
+      def inspect
+        @@to_s.bind(self).call
+      end
     end
 
     private
diff --git a/lib/uri/rfc3986_parser.rb b/lib/uri/rfc3986_parser.rb
index 49a594c..3e07de4 100644
--- a/lib/uri/rfc3986_parser.rb
+++ b/lib/uri/rfc3986_parser.rb
@@ -79,8 +79,14 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/uri/rfc3986_parser.rb#L79
     end
 
     @@to_s = Kernel.instance_method(:to_s)
-    def inspect
-      @@to_s.bind_call(self)
+    if @@to_s.respond_to?(:bind_call)
+      def inspect
+        @@to_s.bind_call(self)
+      end
+    else
+      def inspect
+        @@to_s.bind(self).call
+      end
     end
 
     private
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]