diff options
-rw-r--r-- | encoding.c | 2 | ||||
-rw-r--r-- | test/ruby/test_io.rb | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/encoding.c b/encoding.c index d130eb2612..10a0ab0371 100644 --- a/encoding.c +++ b/encoding.c @@ -803,7 +803,7 @@ rb_enc_get_index(VALUE obj) 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; diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 27077b425b..eeda96c9ef 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -3855,4 +3855,11 @@ __END__ 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 |