ruby-changes:73985
From: Samuel <ko1@a...>
Date: Fri, 14 Oct 2022 21:46:15 +0900 (JST)
Subject: [ruby-changes:73985] d416205341 (master): Copy `IO#timeout` on `IO#dup`. (#6546)
https://git.ruby-lang.org/ruby.git/commit/?id=d416205341 From d4162053410782a449e0921ee7222e7ce3deca6f Mon Sep 17 00:00:00 2001 From: Samuel Williams <samuel.williams@o...> Date: Sat, 15 Oct 2022 01:45:51 +1300 Subject: Copy `IO#timeout` on `IO#dup`. (#6546) --- io.c | 1 + test/ruby/test_io.rb | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/io.c b/io.c index 99513573d7..2fe092b84e 100644 --- a/io.c +++ b/io.c @@ -8407,6 +8407,7 @@ rb_io_init_copy(VALUE dest, VALUE io) https://github.com/ruby/ruby/blob/trunk/io.c#L8407 fptr->encs = orig->encs; fptr->pid = orig->pid; fptr->lineno = orig->lineno; + fptr->timeout = orig->timeout; if (!NIL_P(orig->pathv)) fptr->pathv = orig->pathv; fptr_copy_finalizer(fptr, orig); diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 0c8beb2f95..989c4c8991 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -1441,6 +1441,14 @@ class TestIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L1441 End end + def test_dup_timeout + with_pipe do |r, w| + r.timeout = 0.1 + r2 = r.dup + assert_equal(0.1, r2.timeout) + end + end + def test_inspect with_pipe do |r, w| assert_match(/^#<IO:fd \d+>$/, r.inspect) -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/