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

ruby-changes:65366

From: usa <ko1@a...>
Date: Sun, 28 Feb 2021 23:44:36 +0900 (JST)
Subject: [ruby-changes:65366] e31ab1a240 (ruby_2_6): merge revision(s) 8b6e2685: [Backport #16649]

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

From e31ab1a240add146943eb0492d9929c6c92174b6 Mon Sep 17 00:00:00 2001
From: usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
Date: Sun, 28 Feb 2021 14:44:22 +0000
Subject: merge revision(s) 8b6e2685: [Backport #16649]

	Fixed symbol misused as ID

	rb_funcallv_public and rb_respond_to require an ID, not a
	Symbol. [Bug #16649]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67901 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
---
 common.mk                   | 1 +
 test/ruby/test_transcode.rb | 8 ++++++++
 transcode.c                 | 8 ++++----
 version.h                   | 2 +-
 4 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/common.mk b/common.mk
index c5947ff..4f72928 100644
--- a/common.mk
+++ b/common.mk
@@ -2985,6 +2985,7 @@ transcode.$(OBJEXT): $(top_srcdir)/include/ruby.h https://github.com/ruby/ruby/blob/trunk/common.mk#L2985
 transcode.$(OBJEXT): {$(VPATH)}config.h
 transcode.$(OBJEXT): {$(VPATH)}defines.h
 transcode.$(OBJEXT): {$(VPATH)}encoding.h
+transcode.$(OBJEXT): {$(VPATH)}id.h
 transcode.$(OBJEXT): {$(VPATH)}intern.h
 transcode.$(OBJEXT): {$(VPATH)}internal.h
 transcode.$(OBJEXT): {$(VPATH)}io.h
diff --git a/test/ruby/test_transcode.rb b/test/ruby/test_transcode.rb
index 44d238f..7f81cbf 100644
--- a/test/ruby/test_transcode.rb
+++ b/test/ruby/test_transcode.rb
@@ -2161,6 +2161,14 @@ class TestTranscode < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_transcode.rb#L2161
     assert_equal("U+3042", "\u{3042}".encode("US-ASCII", fallback: fallback.method(:escape)))
   end
 
+  def test_fallback_aref
+    fallback = Object.new
+    def fallback.[](x)
+      "U+%.4X" % x.unpack("U")
+    end
+    assert_equal("U+3042", "\u{3042}".encode("US-ASCII", fallback: fallback))
+  end
+
   bug8940 = '[ruby-core:57318] [Bug #8940]'
   %w[UTF-32 UTF-16].each do |enc|
     define_method("test_pseudo_encoding_inspect(#{enc})") do
diff --git a/transcode.c b/transcode.c
index 5f9e4e9..55ff30c 100644
--- a/transcode.c
+++ b/transcode.c
@@ -12,6 +12,7 @@ https://github.com/ruby/ruby/blob/trunk/transcode.c#L12
 #include "ruby/encoding.h"
 #include "internal.h"
 #include "transcode_data.h"
+#include "id.h"
 #include <ctype.h>
 
 #define ENABLE_ECONV_NEWLINE_OPTION 1
@@ -23,7 +24,7 @@ static VALUE rb_eConverterNotFoundError; https://github.com/ruby/ruby/blob/trunk/transcode.c#L24
 
 VALUE rb_cEncodingConverter;
 
-static VALUE sym_invalid, sym_undef, sym_replace, sym_fallback, sym_aref;
+static VALUE sym_invalid, sym_undef, sym_replace, sym_fallback;
 static VALUE sym_xml, sym_text, sym_attr;
 static VALUE sym_universal_newline;
 static VALUE sym_crlf_newline;
@@ -2256,7 +2257,7 @@ method_fallback(VALUE fallback, VALUE c) https://github.com/ruby/ruby/blob/trunk/transcode.c#L2257
 static VALUE
 aref_fallback(VALUE fallback, VALUE c)
 {
-    return rb_funcall3(fallback, sym_aref, 1, &c);
+    return rb_funcallv_public(fallback, idAREF, 1, &c);
 }
 
 static void
@@ -2550,7 +2551,7 @@ rb_econv_prepare_options(VALUE opthash, VALUE *opts, int ecflags) https://github.com/ruby/ruby/blob/trunk/transcode.c#L2551
     if (!NIL_P(v)) {
 	VALUE h = rb_check_hash_type(v);
 	if (NIL_P(h)
-	    ? (rb_obj_is_proc(v) || rb_obj_is_method(v) || rb_respond_to(v, sym_aref))
+	    ? (rb_obj_is_proc(v) || rb_obj_is_method(v) || rb_respond_to(v, idAREF))
 	    : (v = h, 1)) {
 	    if (NIL_P(newhash))
 		newhash = rb_hash_new();
@@ -4424,7 +4425,6 @@ Init_transcode(void) https://github.com/ruby/ruby/blob/trunk/transcode.c#L4425
     sym_undef = ID2SYM(rb_intern("undef"));
     sym_replace = ID2SYM(rb_intern("replace"));
     sym_fallback = ID2SYM(rb_intern("fallback"));
-    sym_aref = ID2SYM(rb_intern("[]"));
     sym_xml = ID2SYM(rb_intern("xml"));
     sym_text = ID2SYM(rb_intern("text"));
     sym_attr = ID2SYM(rb_intern("attr"));
diff --git a/version.h b/version.h
index d08a24b..ed7f10b 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L1
 #define RUBY_VERSION "2.6.7"
 #define RUBY_RELEASE_DATE "2021-02-28"
-#define RUBY_PATCHLEVEL 160
+#define RUBY_PATCHLEVEL 161
 
 #define RUBY_RELEASE_YEAR 2021
 #define RUBY_RELEASE_MONTH 2
-- 
cgit v1.1


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

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