From 4153773cfc325aceff6133ede8713b6378ce8197 Mon Sep 17 00:00:00 2001 From: Herwin Date: Sat, 28 Dec 2024 20:37:53 +0100 Subject: [PATCH] Update Thread#thread_variable_get to match Ruby 3.4 behaviour --- spec/core/thread/thread_variable_get_spec.rb | 10 +++------- src/thread_object.cpp | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/spec/core/thread/thread_variable_get_spec.rb b/spec/core/thread/thread_variable_get_spec.rb index ecacb3a148..1ea34cf2b3 100644 --- a/spec/core/thread/thread_variable_get_spec.rb +++ b/spec/core/thread/thread_variable_get_spec.rb @@ -48,17 +48,13 @@ ruby_version_is '3.4' do it "raises a TypeError if the key is neither Symbol nor String when no thread variables are set" do - NATFIXME 'it raises a TypeError if the key is neither Symbol nor String when no thread variables are set', exception: SpecFailedException do - -> { @t.thread_variable_get(123) }.should raise_error(TypeError, /123 is not a symbol/) - end + -> { @t.thread_variable_get(123) }.should raise_error(TypeError, /123 is not a symbol/) end it "raises a TypeError if the key is neither Symbol nor String without calling #to_sym" do key = mock('key') - NATFIXME 'it raises a TypeError if the key is neither Symbol nor String without calling #to_sym', exception: SpecFailedException do - key.should_not_receive(:to_sym) - -> { @t.thread_variable_get(key) }.should raise_error(TypeError, /#{Regexp.escape(key.inspect)} is not a symbol/) - end + key.should_not_receive(:to_sym) + -> { @t.thread_variable_get(key) }.should raise_error(TypeError, /#{Regexp.escape(key.inspect)} is not a symbol/) end end end diff --git a/src/thread_object.cpp b/src/thread_object.cpp index 444564f866..74992e2ca2 100644 --- a/src/thread_object.cpp +++ b/src/thread_object.cpp @@ -570,9 +570,9 @@ bool ThreadObject::has_thread_variable(Env *env, Value key) const { } Value ThreadObject::thread_variable_get(Env *env, Value key) { + key = validate_key(env, key); if (!m_thread_variables) return NilObject::the(); - key = validate_key(env, key); return m_thread_variables->ref(env, key); }