From: deepjungle.maca@... Date: 2015-12-17T03:23:25+00:00 Subject: [ruby-core:72204] [Ruby trunk - Bug #11827] StringIO with set_encoding broken with enabled frozen string literal Issue #11827 has been updated by deepj #. Shugo Maeda wrote: > > What behavior do you expect? Not throw the exception in this case. I guess this is a better example https://github.com/rack/rack/blob/master/lib/rack/mock.rb#L139 Here is set encoding for IO classes included StringIO. When the frozen string literal is enabled it causes a problem obviously. And there is no way (at least I haven't figured out it) how to change the encoding for StringIO with frozen string. For me it wouldn't be any difference with I have a StringIO with a frozen string, or a File. It's just a interface with same expected behaviour of IO-like classes. I might be wrong here. ---------------------------------------- Bug #11827: StringIO with set_encoding broken with enabled frozen string literal https://bugs.ruby-lang.org/issues/11827#change-55615 * Author: deepj # * Status: Feedback * Priority: Normal * Assignee: * ruby -v: ruby 2.3.0preview2 (2015-12-11 trunk 53028) [x86_64-darwin15] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- I'm not sure if this the following problem is an expected behavior. But I guess, it is a bug when I run the code below. It throws `set_encoding': can't modify frozen String (RuntimeError). ~~~ # frozen_string_literal: true io = StringIO.new('') io.set_encoding(Encoding::BINARY) ~~~ I wouldn't expect this kind of behavior. -- https://bugs.ruby-lang.org/