diff options
author | Lars Kanis <[email protected]> | 2021-08-16 13:11:30 +0200 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2021-08-22 10:33:22 +0900 |
commit | 6594623f623a0982da62cc105094da0701d499da (patch) | |
tree | 75d34cda3a7c66ed4ce62bbe2f172876b0bbdcdd /test/ruby/test_io.rb | |
parent | c527d278a3dd94b9f5b82769fb69ee7b92b6d6a9 (diff) |
Fix Marshal.dump(closed_io) to raise TypeError and allow encoding on closed IO
Mashalling a closed IO object raised "closed stream (IOError)" before instead of TypeError.
This changes IO#(in|ex)ternal_encoding to still return the encoding even if the underlying FD is closed.
Fixes bug #18077
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4758
Diffstat (limited to 'test/ruby/test_io.rb')
-rw-r--r-- | test/ruby/test_io.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index f7240c4cf6..a90140fd0b 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -3991,6 +3991,18 @@ __END__ } end + def test_marshal_closed_io + bug18077 = '[ruby-core:104927] [Bug #18077]' + r, w = IO.pipe + r.close; w.close + assert_raise(TypeError, bug18077) {Marshal.dump(r)} + + class << r + undef_method :closed? + end + assert_raise(TypeError, bug18077) {Marshal.dump(r)} + end + def test_stdout_to_closed_pipe EnvUtil.invoke_ruby(["-e", "loop {puts :ok}"], "", true, true) do |in_p, out_p, err_p, pid| |