[#83096] File.setuid? on IO (Re: [ruby-cvs:67289] normal:r60108 (trunk): file.c: release GVL in File.{setuid?, setgid?, sticky?}) — Nobuyoshi Nakada <nobu@...>
On 2017/10/04 8:47, normal@ruby-lang.org wrote:
5 messages
2017/10/04
[#83100] Re: File.setuid? on IO (Re: [ruby-cvs:67289] normal:r60108 (trunk): file.c: release GVL in File.{setuid?, setgid?, sticky?})
— Eric Wong <normalperson@...>
2017/10/04
Nobuyoshi Nakada <nobu@ruby-lang.org> wrote:
[#83105] Re: File.setuid? on IO (Re: [ruby-cvs:67289] normal:r60108 (trunk): file.c: release GVL in File.{setuid?, setgid?, sticky?})
— Nobuyoshi Nakada <nobu@...>
2017/10/04
On 2017/10/04 15:55, Eric Wong wrote:
[#83107] Alias Enumerable#include? to Enumerable#includes? — Alberto Almagro <albertoalmagro@...>
Hello,
9 messages
2017/10/04
[#83113] Re: Alias Enumerable#include? to Enumerable#includes?
— "Urabe, Shyouhei" <shyouhei@...>
2017/10/05
This has been requested countless times, then rejected each and every time.
[#83129] Re: Alias Enumerable#include? to Enumerable#includes?
— Alberto Almagro <albertoalmagro@...>
2017/10/05
Sorry I didn't found it on the core mail list's archive.
[#83138] Re: Alias Enumerable#include? to Enumerable#includes?
— "Urabe, Shyouhei" <shyouhei@...>
2017/10/06
Ruby has not been made of popular votes so far. You have to show us
[#83149] Re: Alias Enumerable#include? to Enumerable#includes?
— Eric Wong <normalperson@...>
2017/10/06
Alberto Almagro <albertoalmagro@gmail.com> wrote:
[#83200] [Ruby trunk Feature#13996] [PATCH] file.c: apply2files releases GVL — normalperson@...
Issue #13996 has been reported by normalperson (Eric Wong).
4 messages
2017/10/10
[ruby-core:83529] [Ruby trunk Feature#14042] IO#puts: use writev if available
From:
rohitpaulk@...
Date:
2017-10-23 13:13:20 UTC
List:
ruby-core #83529
Issue #14042 has been updated by rohitpaulk (Paul Kuruvilla).
> Would it make sense to add a deprecation warning in this case? i.e. If the receiver doesn't accept multiple arguments, we emit a deprecation warning and make 2 calls instead of one. If the receiver accepts multiple arguments, we make a single call.
Something along the lines of...
~~~diff
rb_io_writev(VALUE io, int argc, VALUE *argv)
{
- return rb_funcallv(io, id_write, argc, argv);
+ if (rb_obj_method_arity(io, id_write) == -1) {
+ rb_funcallv(io, id_write, argc, argv);
+ }
+ else {
+ /**
+ * Previously, IO#write only accepted one argument. This was changed
+ * to use multiple arguments in revision #60343.
+ *
+ * To play well with programs that might've mocked an IO object and are
+ * only expecting a single argument - let's make multiple calls with
+ * a single argument each.
+ */
+ rb_warn("IO#write has been changed to accept multiple arguments. \
+You are seeing this warning because an object expected to implement the IO \
+interface has a #write method that doesn't accept multiple arguments. Please \
+change the implementation to accept multiple arguments.");
+ for (int i = 0; i < argc; i++) {
+ rb_io_write(io, argv[i]);
+ }
+ }
}
~~~
~~~diff
+ def test_puts_works_with_io_objects_that_only_accept_single_arg
+ klass = Class.new do
+ attr_reader :captured
+
+ def write(str)
+ (@captured ||= "") << str
+ end
+ end
+
+ mocked_io_obj = klass.new
+ old_stdout, $stdout = $stdout, mocked_io_obj
+ puts "hey" # Should write to the mocked class
+ assert_equal("hey\n", mocked_io_obj.captured)
+ ensure
+ $stdout = old_stdout
+ end
+
~~~
----------------------------------------
Feature #14042: IO#puts: use writev if available
https://bugs.ruby-lang.org/issues/14042#change-67555
* Author: rohitpaulk (Paul Kuruvilla)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
Hi,
I've attached a patch to make IO#puts use writev if available. Currently, IO#puts calls `write` twice: Once to write the string, and the second to write a newline (if the string doesn't end with one already). With this patch, those two calls are replaced with a single `writev` call.
A test has been added that demonstrates the problem.
For a bit of background:
* A related issue: https://bugs.ruby-lang.org/issues/9420. (I couldn't figure out a way to 'attach' my patch to that issue, so I'm creating a new one)
* A blog post I wrote a while back about this: https://hackernoon.com/rubys-puts-is-not-atomic-889c57fc9a28
Command I used to run the test I added: `make test-all TESTS='ruby/test_io.rb -n test_puts_parallel'`
I'm a first time contributor, a bit confused as to where a changelog entry should be added. Is the `NEWS` file the right place?
Regards,
Paul
---Files--------------------------------
ruby-changes.patch (2.83 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>