Skip to content

Commit 42ee1e9

Browse files
committed
Add checks in IO to match new specs
1 parent f6fead7 commit 42ee1e9

File tree

1 file changed

+5
-2
lines changed
  • src/main/ruby/truffleruby/core

1 file changed

+5
-2
lines changed

src/main/ruby/truffleruby/core/io.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,7 @@ def binmode
10651065
end
10661066

10671067
def binmode?
1068+
ensure_open
10681069
!Primitive.nil?(@binmode)
10691070
end
10701071

@@ -1454,6 +1455,7 @@ def eof?
14541455
end
14551456

14561457
def external_encoding
1458+
ensure_open
14571459
if @mode & FMODE_WRITABLE == 0
14581460
@external || Encoding.default_external
14591461
else
@@ -1487,6 +1489,7 @@ def fcntl(command, arg=0)
14871489
end
14881490

14891491
def internal_encoding
1492+
ensure_open
14901493
@internal
14911494
end
14921495

@@ -1611,7 +1614,7 @@ def gets(sep_or_limit=$/, limit=nil)
16111614
# f.gets #=> "This is line two\n"
16121615
# f.lineno #=> 2
16131616
def lineno
1614-
ensure_open
1617+
ensure_open_and_readable
16151618
@lineno
16161619
end
16171620

@@ -1628,7 +1631,7 @@ def lineno
16281631
# f.gets #=> "This is line two\n"
16291632
# $. # lineno of last read #=> 1001
16301633
def lineno=(line_number)
1631-
ensure_open
1634+
ensure_open_and_readable
16321635
@lineno = Integer(line_number)
16331636
end
16341637

0 commit comments

Comments
 (0)