From: normalperson@... Date: 2018-01-08T11:57:04+00:00 Subject: [ruby-core:84703] [Ruby trunk Bug#14338] IO#write without args seems wrong Issue #14338 has been reported by normalperson (Eric Wong). ---------------------------------------- Bug #14338: IO#write without args seems wrong https://bugs.ruby-lang.org/issues/14338 * Author: normalperson (Eric Wong) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: * Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: REQUIRED ---------------------------------------- ``` "ruby -e STDOUT.write" outputs "#" (without quotes) "ruby -rstringio -e 'p StringIO.new.write'" shows zero bytes written The following restores <= 2.4 behavior for IO#write, but other things (StringIO, OpenSSL, ...) need to be modified, too: diff --git a/io.c b/io.c index eeaf0c021c..0d95d12a9b 100644 --- a/io.c +++ b/io.c @@ -1675,7 +1675,10 @@ io_writev(int argc, VALUE *argv, VALUE io) static VALUE io_write_m(int argc, VALUE *argv, VALUE io) { - if (argc > 1) { + if (argc <= 0) { + rb_error_arity(argc, 1, UNLIMITED_ARGUMENTS); + } + else if (argc > 1) { return io_writev(argc, argv, io); } else { Opinions? Should we raise or just return 0 when no args are given? ``` -- https://bugs.ruby-lang.org/ Unsubscribe: