Skip to content

Commit 58e57a7

Browse files
committed
merge revision(s) r46151,r46165: [Backport ruby#9865]
* io.c (rb_io_fileno, rb_io_inspect): non-modification does not error on frozen IO. [ruby-dev:48241] [Bug ruby#9865] * io.c (rb_io_autoclose_p): Don't raise on frozen IO. * test/lib/minitest/unit.rb: IO#autoclose? may raise IOError. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent fad3a35 commit 58e57a7

File tree

4 files changed

+32
-6
lines changed

4 files changed

+32
-6
lines changed

ChangeLog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
Mon Aug 11 23:38:20 2014 Tanaka Akira <[email protected]>
2+
3+
* io.c (rb_io_autoclose_p): Don't raise on frozen IO.
4+
5+
Mon Aug 11 23:38:20 2014 Nobuyoshi Nakada <[email protected]>
6+
7+
* io.c (rb_io_fileno, rb_io_inspect): non-modification does not
8+
error on frozen IO. [ruby-dev:48241] [Bug #9865]
9+
110
Mon Aug 11 22:34:47 2014 Nobuyoshi Nakada <[email protected]>
211

312
* configure.in (posix_fadvise): disable use of posix_fadvise

io.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1914,10 +1914,10 @@ rb_io_fdatasync(VALUE io)
19141914
static VALUE
19151915
rb_io_fileno(VALUE io)
19161916
{
1917-
rb_io_t *fptr;
1917+
rb_io_t *fptr = RFILE(io)->fptr;
19181918
int fd;
19191919

1920-
GetOpenFile(io, fptr);
1920+
rb_io_check_closed(fptr);
19211921
fd = fptr->fd;
19221922
return INT2FIX(fd);
19231923
}
@@ -1969,7 +1969,7 @@ rb_io_inspect(VALUE obj)
19691969
VALUE result;
19701970
static const char closed[] = " (closed)";
19711971

1972-
fptr = RFILE(rb_io_taint_check(obj))->fptr;
1972+
fptr = RFILE(obj)->fptr;
19731973
if (!fptr) return rb_any_to_s(obj);
19741974
result = rb_str_new_cstr("#<");
19751975
rb_str_append(result, rb_class_name(CLASS_OF(obj)));
@@ -7519,8 +7519,8 @@ rb_io_s_for_fd(int argc, VALUE *argv, VALUE klass)
75197519
static VALUE
75207520
rb_io_autoclose_p(VALUE io)
75217521
{
7522-
rb_io_t *fptr;
7523-
GetOpenFile(io, fptr);
7522+
rb_io_t *fptr = RFILE(io)->fptr;
7523+
rb_io_check_closed(fptr);
75247524
return (fptr->mode & FMODE_PREP) ? Qfalse : Qtrue;
75257525
}
75267526

test/ruby/test_io.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,8 @@ def test_dup_many
11221122
def test_inspect
11231123
with_pipe do |r, w|
11241124
assert_match(/^#<IO:fd \d+>$/, r.inspect)
1125+
r.freeze
1126+
assert_match(/^#<IO:fd \d+>$/, r.inspect)
11251127
end
11261128
end
11271129

@@ -2751,6 +2753,21 @@ def test_std_fileno
27512753
assert_equal(2, $stderr.fileno)
27522754
end
27532755

2756+
def test_frozen_fileno
2757+
bug9865 = '[ruby-dev:48241] [Bug #9865]'
2758+
with_pipe do |r,w|
2759+
fd = r.fileno
2760+
assert_equal(fd, r.freeze.fileno, bug9865)
2761+
end
2762+
end
2763+
2764+
def test_frozen_autoclose
2765+
with_pipe do |r,w|
2766+
fd = r.fileno
2767+
assert_equal(true, r.freeze.autoclose?)
2768+
end
2769+
end
2770+
27542771
def test_sysread_locktmp
27552772
bug6099 = '[ruby-dev:45297]'
27562773
buf = " " * 100

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.1.2"
22
#define RUBY_RELEASE_DATE "2014-08-11"
3-
#define RUBY_PATCHLEVEL 198
3+
#define RUBY_PATCHLEVEL 199
44

55
#define RUBY_RELEASE_YEAR 2014
66
#define RUBY_RELEASE_MONTH 8

0 commit comments

Comments
 (0)