8000 Ensure crr->feature is an fstring · ruby/ruby@fc54ae5 · GitHub
[go: up one dir, main page]

Skip to content

Commit fc54ae5

Browse files
committed
Ensure crr->feature is an fstring
1 parent 72709a6 commit fc54ae5

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

ractor.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,8 +2339,8 @@ rb_ractor_require(VALUE feature)
23392339
VALUE crr_obj = TypedData_Make_Struct(0, struct cross_ractor_require, &cross_ractor_require_data_type, crr);
23402340
FL_SET_RAW(crr_obj, RUBY_FL_SHAREABLE);
23412341

2342-
// TODO: make feature shareable
2343-
crr->feature = feature;
2342+
// Convert feature to proper file path and make it shareable as fstring
2343+
crr->feature = rb_fstring(FilePathValue(feature));
23442344
crr->port = ractor_port_new(GET_RACTOR());
23452345
crr->result = Qundef;
23462346
crr->exception = Qundef;

test/ruby/test_ractor.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,21 @@ def test_require_raises_and_no_ractor_belonging_issue
9898
RUBY
9999
end
100100

101+
def test_require_non_string
102+
assert_ractor(<<~'RUBY')
103+
require "tempfile"
104+
require "pathname"
105+
f = Tempfile.new(["file_to_require_from_ractor", ".rb"])
106+
f.write("puts 'success'")
107+
f.flush
108+
result = Ractor.new(f.path) do |path|
109+
require Pathname.new(path)
110+
"success"
111+
end.value
112+
assert_equal "success", result
113+
RUBY
114+
end
115+
101116
def assert_make_shareable(obj)
102117
refute Ractor.shareable?(obj), "object was already shareable"
103118
Ractor.make_shareable(obj)

0 commit comments

Comments
 (0)
0