[Bug #21509] [DOC] Correct IO#wait description

This commit is contained in:
Nobuyoshi Nakada 2025-07-12 22:21:43 +09:00
parent dbf7a0c713
commit 9e7a985c6d
No known key found for this signature in database
GPG key ID: 3582D74E1FEE4465

16
io.c
View file

@ -9929,7 +9929,7 @@ io_event_from_value(VALUE value)
/* /*
* call-seq: * call-seq:
* io.wait(events, timeout) -> event mask, false or nil * io.wait(events, timeout) -> event mask, false or nil
* io.wait(timeout = nil, mode = :read) -> self, true, or false * io.wait(*event_symbols[, timeout]) -> self, true, or false
* *
* Waits until the IO becomes ready for the specified events and returns the * Waits until the IO becomes ready for the specified events and returns the
* subset of events that become ready, or a falsy value when times out. * subset of events that become ready, or a falsy value when times out.
@ -9937,10 +9937,14 @@ io_event_from_value(VALUE value)
* The events can be a bit mask of +IO::READABLE+, +IO::WRITABLE+ or * The events can be a bit mask of +IO::READABLE+, +IO::WRITABLE+ or
* +IO::PRIORITY+. * +IO::PRIORITY+.
* *
* Returns an event mask (truthy value) immediately when buffered data is available. * Returns an event mask (truthy value) immediately when buffered data is
* available.
* *
* Optional parameter +mode+ is one of +:read+, +:write+, or * The second form: if one or more event symbols (+:read+, +:write+, or
* +:read_write+. * +:read_write+) are passed, the event mask is the bit OR of the bitmask
* corresponding to those symbols. In this form, +timeout+ is optional, the
* order of the arguments is arbitrary, and returns +io+ if any of the
* events is ready.
*/ */
static VALUE static VALUE
@ -9950,10 +9954,6 @@ io_wait(int argc, VALUE *argv, VALUE io)
enum rb_io_event events = 0; enum rb_io_event events = 0;
int return_io = 0; int return_io = 0;
// The documented signature for this method is actually incorrect.
// A single timeout is allowed in any position, and multiple symbols can be given.
// Whether this is intentional or not, I don't know, and as such I consider this to
// be a legacy/slow path.
if (argc != 2 || (RB_SYMBOL_P(argv[0]) || RB_SYMBOL_P(argv[1]))) { if (argc != 2 || (RB_SYMBOL_P(argv[0]) || RB_SYMBOL_P(argv[1]))) {
// We'd prefer to return the actual mask, but this form would return the io itself: // We'd prefer to return the actual mask, but this form would return the io itself:
return_io = 1; return_io = 1;