Skip to content

Commit 3f90fe4

Browse files
authored
Allow seek when underlying string is frozen (#121)
Fixes#119. Adds a test for this expectation.
1 parent 3f56884 commit 3f90fe4

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎ext/java/org/jruby/ext/stringio/StringIO.java‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,8 +1356,6 @@ public IRubyObject seek(ThreadContext context, IRubyObject arg0, IRubyObject arg
13561356
}
13571357

13581358
privateRubyFixnumseekCommon(ThreadContextcontext, intargc, IRubyObjectarg0, IRubyObjectarg1) {
1359-
checkModifiable();
1360-
13611359
Rubyruntime = context.runtime;
13621360

13631361
IRubyObjectwhence = context.nil;
@@ -1367,10 +1365,10 @@ private RubyFixnum seekCommon(ThreadContext context, int argc, IRubyObject arg0,
13671365
whence = arg1;
13681366
}
13691367

1370-
checkOpen();
1371-
13721368
StringIODataptr = this.getPtr();
13731369

1370+
checkOpen();
1371+
13741372
booleanlocked = lock(context, ptr);
13751373
try {
13761374
switch (whence.isNil() ? 0 : RubyNumeric.num2int(whence)) {

‎test/stringio/test_stringio.rb‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,11 @@ def test_seek
483483
f.closeunlessf.closed?
484484
end
485485

486+
deftest_seek_frozen_string
487+
f=StringIO.new(-"1234")
488+
assert_equal(0,f.seek(1))
489+
end
490+
486491
deftest_each_byte
487492
f=StringIO.new("1234")
488493
a=[]

0 commit comments

Comments
 (0)