Issue #18077 has been updated by nobu (Nobuyoshi Nakada).


Since this is a bug report, I think that the old example in rubyspec should be removed.

----------------------------------------
Bug #18077: Marshal.dump(closed_io) raises IOError instead of TypeError
https://bugs.ruby-lang.org/issues/18077#change-93449

* Author: larskanis (Lars Kanis)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.1.0dev (2021-08-16T08:00:19Z master a8714b83c4) [x86_64-linux]
* Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
Marshal.dump is expected to raise a `TypeError` for unmarshallable objects. But closed streams raise an `IOError`:

```
$ ruby -e "io=IO.pipe.first; io.close; Marshal.dump(io)"
-e:1:in `internal_encoding': closed stream (IOError)
	from -e:1:in `dump'
	from -e:1:in `<main>'
```

This issue is present in all current ruby versions. 



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>