[前][次][番号順一覧][スレッド一覧]

ruby-changes:64504

From: Nobuyoshi <ko1@a...>
Date: Wed, 23 Dec 2020 13:51:05 +0900 (JST)
Subject: [ruby-changes:64504] c0a2d95cf3 (master): Update rb_ractor_ensure_shareable

https://git.ruby-lang.org/ruby.git/commit/?id=c0a2d95cf3

From c0a2d95cf318cf9b9ffe23f0a4b8720f69775448 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Tue, 22 Dec 2020 08:26:42 +0900
Subject: Update rb_ractor_ensure_shareable

* Fixed use of rb_ractor_shareable_p
* Raise Ractor::IsolationError

diff --git a/ractor.c b/ractor.c
index 484b5c7..585435c 100644
--- a/ractor.c
+++ b/ractor.c
@@ -2445,10 +2445,10 @@ rb_ractor_make_shareable_copy(VALUE obj) https://github.com/ruby/ruby/blob/trunk/ractor.c#L2445
 VALUE
 rb_ractor_ensure_shareable(VALUE obj, VALUE name)
 {
-    if (!RTEST(rb_ractor_shareable_p(obj))) {
+    if (!rb_ractor_shareable_p(obj)) {
         VALUE message = rb_sprintf("cannot assign unshareable object to %"PRIsVALUE,
                                    name);
-        rb_exc_raise(rb_exc_new_str(rb_eRactorError, message));
+        rb_exc_raise(rb_exc_new_str(rb_eRactorIsolationError, message));
     }
     return obj;
 }
diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb
index 8d12538..aeaa42d 100644
--- a/test/ruby/test_parse.rb
+++ b/test/ruby/test_parse.rb
@@ -1178,8 +1178,8 @@ x = __ENCODING__ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_parse.rb#L1178
     Class.new.class_eval(code)
   end
 
-  def assert_ractor_error(message, code)
-    assert_raise_with_message(Ractor::Error, message) do
+  def assert_raise_separately(error, message, code)
+    assert_raise_with_message(error, message) do
       eval_separately(code)
     end
   end
@@ -1243,7 +1243,8 @@ x = __ENCODING__ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_parse.rb#L1243
   end
 
   def test_shareable_constant_value_unshareable_literal
-    assert_ractor_error(/unshareable/, "#{<<~"begin;"}\n#{<<~'end;'}")
+    assert_raise_separately(Ractor::IsolationError, /unshareable/,
+                            "#{<<~"begin;"}\n#{<<~'end;'}")
     begin;
       # shareable_constant_value: literal
       C = ["Not " + "shareable"]
@@ -1264,7 +1265,8 @@ x = __ENCODING__ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_parse.rb#L1265
   end
 
   def test_shareable_constant_value_unfrozen
-    assert_ractor_error(/does not freeze object correctly/, "#{<<~"begin;"}\n#{<<~'end;'}")
+    assert_raise_separately(Ractor::Error, /does not freeze object correctly/,
+                            "#{<<~"begin;"}\n#{<<~'end;'}")
     begin;
       # shareable_constant_value: experimental_everything
       o = Object.new
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]