[PATCH] StringIO#each_byte fails with NoMethodError when the current position is out of bounds
Reported by Janico Greifenberg | July 22nd, 2008 @ 10:59 AM | in 1.0 preview
The spec for StringIO#each_byte produces the following error:
$ bin/mspec spec/ruby/1.8/library/stringio/
rubinius 0.9.0 (ruby 1.8.6 compatible) (b55c3b1fa) (07/22/2008) [i686-pc-linux-gnu]
............................E...............................................................................................................................................................................................................................................................................................................................
1)
StringIO#each_byte does not yield if the current position is out of bounds ERROR
NoMethodError: No method 'each_byte' on an instance of NilClass.
Kernel(NilClass)#each_byte (method_missing_cv) at kernel/core/kernel.rb:652
StringIO#each_byte at /home/jgre/software/rbx/lib/stringio.rb:118
Object#__script__ {} at ./spec/ruby/1.8/library/stringio/shared/each_byte.rb:21
Kernel(Object)#instance_eval at kernel/core/eval.rb:103
Proc#call at kernel/core/proc.rb:76
Enumerable(Array)#all? {} at kernel/core/enumerable.rb:462
Array#each at kernel/core/array.rb:572
Enumerable(Array)#all? at kernel/core/enumerable.rb:462
Array#each at kernel/core/array.rb:572
Object#__script__ at ./spec/ruby/1.8/library/stringio//each_byte_spec.rb:9
CompiledMethod#as_script at kernel/core/compiled_method.rb:407
Compile.single_load at kernel/core/compile.rb:248
Compile.unified_load {} at kernel/core/compile.rb:161
Array#each at kernel/core/array.rb:572
Compile.unified_load at kernel/core/compile.rb:127
Kernel.load at kernel/core/compile.rb:408
Kernel(Object)#instance_eval at kernel/core/eval.rb:103
Array#each at kernel/core/array.rb:572
CompiledMethod#as_script at kernel/core/compiled_method.rb:407
Compile.single_load at kernel/core/compile.rb:248
Compile.load_from_extension at kernel/core/compile.rb:326
Object#__script__ at kernel/loader.rb:221
Finished in 1.362595 seconds
55 files, 348 examples, 666 expectations, 0 failures, 1 error
The patch checks the position against the length of the contained string before delegating to String#each_byte.
After applying the patch, the spec runs without errors:
$ bin/mspec spec/ruby/1.8/library/stringio/
rubinius 0.9.0 (ruby 1.8.6 compatible) (b55c3b1fa) (07/22/2008) [i686-pc-linux-gnu]
............................................................................................................................................................................................................................................................................................................................................................
Finished in 1.361265 seconds
55 files, 348 examples, 667 expectations, 0 failures, 0 errors
Comments and changes to this ticket
-
Federico Builes July 24th, 2008 @ 06:15 PM
- → State changed from new to resolved
Thanks for the patch Janico, it's been applied in a6b85351. If you're interested in a commit bit let evan know on IRC.
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
