ruby-changes:63036
From: Benoit <ko1@a...>
Date: Mon, 21 Sep 2020 23:24:37 +0900 (JST)
Subject: [ruby-changes:63036] 82998918ef (master): Make Thread#join always convert its argument, as before 70f08f1eed
https://git.ruby-lang.org/ruby.git/commit/?id=82998918ef From 82998918efa3a637c80e135198b573cfcb31acd9 Mon Sep 17 00:00:00 2001 From: Benoit Daloze <eregontp@g...> Date: Mon, 21 Sep 2020 16:22:04 +0200 Subject: Make Thread#join always convert its argument, as before 70f08f1eed diff --git a/spec/ruby/core/thread/join_spec.rb b/spec/ruby/core/thread/join_spec.rb index 06e9049..213fe2e 100644 --- a/spec/ruby/core/thread/join_spec.rb +++ b/spec/ruby/core/thread/join_spec.rb @@ -22,11 +22,10 @@ describe "Thread#join" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/thread/join_spec.rb#L22 end it "raises TypeError if the argument is not a valid timeout" do - t = Thread.new { sleep } + t = Thread.new { } + t.join -> { t.join(:foo) }.should raise_error TypeError -> { t.join("bar") }.should raise_error TypeError - t.kill - t.join end it "returns nil if it is not finished when given a timeout" do diff --git a/thread.c b/thread.c index d6a4f7a..510d8a0 100644 --- a/thread.c +++ b/thread.c @@ -1313,6 +1313,17 @@ thread_join_m(int argc, VALUE *argv, VALUE self) https://github.com/ruby/ruby/blob/trunk/thread.c#L1313 timeout = argv[0]; } + // Convert the timeout eagerly, so it's always converted and deterministic + if (timeout == Qnil) { + /* unlimited */ + } + else if (FIXNUM_P(timeout)) { + /* handled directly in thread_join_sleep() */ + } + else { + timeout = rb_to_float(timeout); + } + return thread_join(rb_thread_ptr(self), timeout); } -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/