Skip to content

[Bug #19624] Hide internal IO for backquote #7776

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions io.c
Original file line number Diff line number Diff line change
Expand Up @@ -10497,6 +10497,7 @@ rb_f_backquote(VALUE obj, VALUE str)
if (NIL_P(port)) return rb_str_new(0,0);

GetOpenFile(port, fptr);
rb_obj_hide(port);
result = read_all(fptr, remain_size(fptr), Qnil);
rb_io_close(port);
RFILE(port)->fptr = NULL;
Expand Down
13 changes: 13 additions & 0 deletions test/ruby/test_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,19 @@ class << message
end
end

def test_system_closed
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
begin;
ios = []
ObjectSpace.each_object(IO) {|io| ios << io}
`echo`
ObjectSpace.each_object(IO) do |io|
next if ios.include?(io)
assert_nothing_raised {io.close}
end
end;
end

def test_empty_evstr
assert_equal("", eval('"#{}"', nil, __FILE__, __LINE__), "[ruby-dev:25113]")
end
Expand Down