summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spec/ruby/optional/capi/string_spec.rb4
-rw-r--r--string.c2
2 files changed, 4 insertions, 2 deletions
diff --git a/spec/ruby/optional/capi/string_spec.rb b/spec/ruby/optional/capi/string_spec.rb
index 27f65c872a..be9cb9015f 100644
--- a/spec/ruby/optional/capi/string_spec.rb
+++ b/spec/ruby/optional/capi/string_spec.rb
@@ -1222,7 +1222,7 @@ describe "C-API String function" do
-> { str.upcase! }.should raise_error(RuntimeError, 'can\'t modify string; temporarily locked')
end
- ruby_bug "#20998", ""..."3.6" do # TODO: check when Ruby 3.5 is released
+ ruby_version_is "3.5" do
it "raises FrozenError if string is frozen" do
str = -"rb_str_locktmp"
-> { @s.rb_str_locktmp(str) }.should raise_error(FrozenError)
@@ -1246,7 +1246,7 @@ describe "C-API String function" do
-> { @s.rb_str_unlocktmp(+"test") }.should raise_error(RuntimeError, 'temporal unlocking already unlocked string')
end
- ruby_bug "#20998", ""..."3.6" do # TODO: check when Ruby 3.5 is released
+ ruby_version_is "3.5" do
it "raises FrozenError if string is frozen" do
str = -"rb_str_locktmp"
-> { @s.rb_str_unlocktmp(str) }.should raise_error(FrozenError)
diff --git a/string.c b/string.c
index d9ffb29b8e..403b8df15f 100644
--- a/string.c
+++ b/string.c
@@ -3664,6 +3664,7 @@ RUBY_ALIAS_FUNCTION(rb_str_dup_frozen(VALUE str), rb_str_new_frozen, (str))
VALUE
rb_str_locktmp(VALUE str)
{
+ rb_check_frozen(str);
if (FL_TEST(str, STR_TMPLOCK)) {
rb_raise(rb_eRuntimeError, "temporal locking already locked string");
}
@@ -3674,6 +3675,7 @@ rb_str_locktmp(VALUE str)
VALUE
rb_str_unlocktmp(VALUE str)
{
+ rb_check_frozen(str);
if (!FL_TEST(str, STR_TMPLOCK)) {
rb_raise(rb_eRuntimeError, "temporal unlocking already unlocked string");
}