Skip to content
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
9 changes: 8 additions & 1 deletion io.c
Original file line number Diff line number Diff line change
Expand Up @@ -2870,8 +2870,15 @@ rb_io_descriptor(VALUE io)
return fptr->fd;
}
else {
return RB_NUM2INT(rb_funcall(io, id_fileno, 0));
VALUE fileno = rb_check_funcall(io, id_fileno, 0, NULL);
if (!UNDEF_P(fileno)) {
return RB_NUM2INT(fileno);
}
}

rb_raise(rb_eTypeError, "expected IO or #fileno, %"PRIsVALUE" given", rb_obj_class(io));

UNREACHABLE_RETURN(-1);
}

int
Expand Down
2 changes: 1 addition & 1 deletion test/ruby/test_io_buffer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_file_mapped
end

def test_file_mapped_invalid
assert_raise NoMethodError do
assert_raise TypeError do
IO::Buffer.map("foobar")
end
end
Expand Down