Project

General

Profile

Actions

Feature #20390

closed

Issue with StringIO and chilled strings

Added by mdalessio (Mike Dalessio) 8 months ago. Updated 8 months ago.

Status:
Closed
Target version:
-
[ruby-core:117305]

Description

StringIO doesn't appear to handle chilled strings in a backwards-compatible way after 12be40ae

require "stringio"

sio = StringIO.new("")
sio.write("hello")

When not specifying a value for frozen-string-literal, the empty string is chilled so I would expect to get a warning but also expect the write to complete.

Instead, the write fails as if the string is frozen:

ruby 3.4.0dev (2024-03-23T16:40:17Z master 8265a7531f) [x86_64-linux]
./issue-stringio-frozen.rb:8:in 'StringIO#write': not opened for writing (IOError)
        from ./issue-stringio-frozen.rb:8:in '<main>'

cc @byroot (Jean Boussier) @etienne (Étienne Barrié)


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #20205: Enable `frozen_string_literal` by defaultClosedmatz (Yukihiro Matsumoto)Actions
Actions

Also available in: Atom PDF

Like0
Like1Like0Like0Like0Like0