From d4b4ec043006f2ccb1c33e4fe9f705fdec458c38 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Fri, 10 Jul 2026 07:51:31 +0200 Subject: [PATCH] Update `str_chilled_p` for Ruby 4.1 [Feature #22137] The only cause for chilled is now literals. `STR_CHILLED_SYMBOL_TO_S` has been removed because `Symbol#to_s` always return a frozen string. --- ext/stringio/stringio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index d863dcc..b97eaa6 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -39,7 +39,11 @@ STRINGIO_VERSION = "3.2.1"; static inline bool str_chilled_p(VALUE str) { -#if (RUBY_API_VERSION_MAJOR == 3 && RUBY_API_VERSION_MINOR >= 4) || RUBY_API_VERSION_MAJOR >= 4 +#if RUBY_API_VERSION_CODE >= 40100 + // Do not attempt to modify chilled strings on Ruby 4.1+ + // RUBY_FL_USER2 == STR_CHILLED + return FL_TEST_RAW(str, RUBY_FL_USER2); +#elif RUBY_API_VERSION_CODE >= 30400 // Do not attempt to modify chilled strings on Ruby 3.4+ // RUBY_FL_USER2 == STR_CHILLED_LITERAL // RUBY_FL_USER3 == STR_CHILLED_SYMBOL_TO_S