Skip to content

Commit ef9301a

Browse files
committed
Ensure crr->feature is an fstring
1 parent b28f344 commit ef9301a

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

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
@@ -118,6 +118,21 @@ def test_require_raises_and_no_ractor_belonging_issue
118118
RUBY
119119
end
120120

121+
def test_require_non_string
122+
assert_ractor(<<~'RUBY')
123+
require "tempfile"
124+
require "pathname"
125+
f = Tempfile.new(["file_to_require_from_ractor", ".rb"])
126+
f.write("puts 'success'")
127+
f.flush
128+
result = Ractor.new(f.path) do |path|
129+
require Pathname.new(path)
130+
"success"
131+
end.value
132+
assert_equal "success", result
133+
RUBY
134+
end
135+
121136
def assert_make_shareable(obj)
122137
refute Ractor.shareable?(obj), "object was already shareable"
123138
Ractor.make_shareable(obj)

0 commit comments

Comments
 (0)