Project

General

Profile

Bug #4437

Hash does not match character read from file via IO#getc

Added by Bob Alexander about 5 years ago. Updated over 3 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
ruby -v:
ruby 1.9.2p136 (2010-12-25) [i386-mingw32]
[ruby-core:<unknown>]

Description

Run this little program, and observe that the single-character read from a file does not match a hash key as it should.

===========================================

Create a file with the single character 'x', then read it back into var x.

open('x', 'w') {|f| f.write('x')}
x = open('x') {|f| f.getc}

Create a Hash with x as a key.

h = {'x' => 'xx'}

Retrieve the value, to show that the hash (of course) works with ordinary

characters.

p 'h["x"] =>', h["x"]
p 'h[?x] =>', h[?x]

Retrieve the value using the 'x' obtained using getc, showing that the

hash match fails for the same character as retrieved from a file.

puts
p 'x =>', x

p 'h[x] =>', h[x]

getc_bug.rb Magnifier - Sample program that shows the error. (516 Bytes) Bob Alexander, 02/24/2011 12:08 PM

History

#1 Updated by Bob Alexander about 5 years ago

=begin
Oops -- my little program was included in the description, but that didn't seem to work out very well, so I'm attaching it.
=end

#2 Updated by Yui NARUSE almost 5 years ago

  • Status changed from Open to Feedback

I can't reproduce this with 1.9.2p188 on FreeBSD.
Can you reproduce with p180 (or latest ruby_1_9_2 branch)?

#3 [ruby-core:48930] Updated by Yusuke Endoh over 3 years ago

  • Status changed from Feedback to Rejected

I can't repro with trunk.

We cannot investigate this issue any more. I'm closing this ticket.
If you can reproduce it, or if you know anything, feel free to reopen.

--
Yusuke Endoh mame@tsg.ne.jp

Also available in: Atom PDF