From: "Eregon (Benoit Daloze)" Date: 2021-08-18T16:51:27+00:00 Subject: [ruby-core:104970] [Ruby master Bug#18077] Marshal.dump(closed_io) raises IOError instead of TypeError Issue #18077 has been updated by Eregon (Benoit Daloze). Why does IO#internal_encoding (and external_encoding) raise if the IO is closed? They could just return the encoding, it's still stored in in the IO instance, and we are not trying to access the `fd`, right? JRuby 9.2.17.0 does not raise, and I think it is the better behavior here. ---------------------------------------- Bug #18077: Marshal.dump(closed_io) raises IOError instead of TypeError https://bugs.ruby-lang.org/issues/18077#change-93335 * 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 `
' ``` This issue is present in all current ruby versions. -- https://bugs.ruby-lang.org/ Unsubscribe: