ruby-changes:63232
From: Samuel <ko1@a...>
Date: Thu, 1 Oct 2020 12:02:22 +0900 (JST)
Subject: [ruby-changes:63232] 13660105e2 (master): Don't call `Scheduler#close` if it doesn't exist.
https://git.ruby-lang.org/ruby.git/commit/?id=13660105e2 From 13660105e225df0a4fc1f91b8c9618261e5761f3 Mon Sep 17 00:00:00 2001 From: Samuel Williams <samuel.williams@o...> Date: Thu, 1 Oct 2020 13:42:58 +1300 Subject: Don't call `Scheduler#close` if it doesn't exist. diff --git a/scheduler.c b/scheduler.c index 8ec5039..f0bb5ee 100644 --- a/scheduler.c +++ b/scheduler.c @@ -39,7 +39,9 @@ Init_Scheduler(void) https://github.com/ruby/ruby/blob/trunk/scheduler.c#L39 VALUE rb_scheduler_close(VALUE scheduler) { - return rb_funcall(scheduler, id_close, 0); + if (rb_respond_to(scheduler, id_close)) { + return rb_funcall(scheduler, id_close, 0); + } } VALUE diff --git a/test/fiber/test_scheduler.rb b/test/fiber/test_scheduler.rb index 23b59c0..d85aa7a 100644 --- a/test/fiber/test_scheduler.rb +++ b/test/fiber/test_scheduler.rb @@ -49,4 +49,12 @@ class TestFiberScheduler < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/fiber/test_scheduler.rb#L49 end RUBY end + + def test_optional_close + thread = Thread.new do + Thread.current.scheduler = Object.new + end + + thread.join + end end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/