ruby-changes:52542
From: nobu <ko1@a...>
Date: Sun, 16 Sep 2018 01:27:14 +0900 (JST)
Subject: [ruby-changes:52542] nobu:r64753 (trunk): encoding.c: check external encoding
nobu 2018-09-16 01:27:06 +0900 (Sun, 16 Sep 2018) New Revision: 64753 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64753 Log: encoding.c: check external encoding * encoding.c (rb_enc_get_index): external encoding may not be Data object. [ruby-core:89016] [Bug #15122] Modified files: trunk/encoding.c trunk/test/ruby/test_io.rb Index: encoding.c =================================================================== --- encoding.c (revision 64752) +++ encoding.c (revision 64753) @@ -803,7 +803,7 @@ rb_enc_get_index(VALUE obj) https://github.com/ruby/ruby/blob/trunk/encoding.c#L803 if (NIL_P(tmp)) { tmp = rb_funcallv(obj, rb_intern("external_encoding"), 0, 0); } - if (is_data_encoding(tmp)) { + if (is_obj_encoding(tmp)) { i = enc_check_encoding(tmp); } break; Index: test/ruby/test_io.rb =================================================================== --- test/ruby/test_io.rb (revision 64752) +++ test/ruby/test_io.rb (revision 64753) @@ -3855,4 +3855,11 @@ __END__ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L3855 th.join end; end + + def test_external_encoding_index + IO.pipe {|r, w| + assert_raise(TypeError) {Marshal.dump(r)} + assert_raise(TypeError) {Marshal.dump(w)} + } + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/