Skip to content

Commit dc62d65

Browse files
byrooteregon
authored andcommitted
Remove special handling of chilled strings
[Feature #20205] Followup: #94 They no longer need to be special cases. If StringIO end up mutating a chilled string, a warning will be emitted.
1 parent 073172d commit dc62d65

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

ext/stringio/stringio.c

+1-11
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,11 @@ static long strio_write(VALUE self, VALUE str);
5151
#define IS_STRIO(obj) (rb_typeddata_is_kind_of((obj), &strio_data_type))
5252
#define error_inval(msg) (rb_syserr_fail(EINVAL, msg))
5353
#define get_enc(ptr) ((ptr)->enc ? (ptr)->enc : !NIL_P((ptr)->string) ? rb_enc_get((ptr)->string) : NULL)
54-
#ifndef HAVE_RB_STR_CHILLED_P
55-
static bool
56-
rb_str_chilled_p(VALUE str)
57-
{
58-
return false;
59-
}
60-
#endif
6154

6255
static bool
6356
readonly_string_p(VALUE string)
6457
{
65-
return OBJ_FROZEN_RAW(string) && !rb_str_chilled_p(string);
58+
return OBJ_FROZEN_RAW(string);
6659
}
6760

6861
static struct StringIO *
@@ -184,9 +177,6 @@ check_modifiable(struct StringIO *ptr)
184177
if (NIL_P(ptr->string)) {
185178
/* Null device StringIO */
186179
}
187-
else if (rb_str_chilled_p(ptr->string)) {
188-
rb_str_modify(ptr->string);
189-
}
190180
else if (OBJ_FROZEN_RAW(ptr->string)) {
191181
rb_raise(rb_eIOError, "not modifiable string");
192182
}

test/stringio/test_stringio.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,8 @@ def test_coderange_after_overwrite
990990
assert_predicate(s.string, :ascii_only?)
991991
end
992992

993-
if eval(%{ "test".frozen? && !"test".equal?("test") }) # Ruby 3.4+ chilled strings
993+
require "objspace"
994+
if ObjectSpace.respond_to?(:dump) && ObjectSpace.dump(eval(%{"test"})).include?('"chilled":true') # Ruby 3.4+ chilled strings
994995
def test_chilled_string
995996
chilled_string = eval(%{""})
996997
io = StringIO.new(chilled_string)

0 commit comments

Comments
 (0)