Bug #7027

Tempfile#inspect is Confusing

Added by Masaki Matsushita about 4 years ago. Updated almost 4 years ago.

ruby -v:
ruby 2.0.0dev (2012-09-15 trunk 36975) [x86_64-linux]


I think Tempfile#inspect is really confusing.
It says Tempfile object is a File, but it is not a File object.

% irb -r tempfile
irb(main):001:0> t ="hoge")
=> #File:/tmp/hoge20120916-12354-uontdm
irb(main):002:0> t.is_a? File
=> false

see also (Japanese):

patch.diff View (337 Bytes) Masaki Matsushita, 09/16/2012 12:18 AM


#1 [ruby-core:47598] Updated by Hans Mackowiak about 4 years ago

in my opinion Delegator should be improved
so it shows that its a Tempfile, but is_a? should also show that its a File or IO

#2 [ruby-core:47610] Updated by Charles Nutter about 4 years ago

In my opinion, Tempfile should not use Delegator at all.

In JRuby, Tempfile actually is a File.

irb(main):001:0> require 'tempfile'
=> true
irb(main):002:0> t ='blah')
=> #Tempfile:/var/folders/9j/yc18czps1x7cbsz76ccl__740000gn/T/blah.77744.52665
irb(main):003:0> t.class
=> Tempfile
irb(main):004:0> t.class.superclass
=> File
irb(main):005:0> t.is_a? File
=> true
irb(main):006:0> Tempfile.ancestors
=> [Tempfile, File, IO, File::Constants, Enumerable, Object, Kernel, BasicObject]

#3 [ruby-core:48894] Updated by Yusuke Endoh almost 4 years ago

  • Target version set to 2.0.0
  • Assignee set to Masaki Matsushita
  • Status changed from Open to Assigned


Sounds good. Please commit it.
If something comes up, we can deal with it then.

Yusuke Endoh

#4 [ruby-core:48967] Updated by Masaki Matsushita almost 4 years ago

  • Status changed from Assigned to Closed

I have commited in r37492.

#5 [ruby-core:48978] Updated by Tomoyuki Chikanaga almost 4 years ago

  • r37493 (for ChangeLog ML, ticket ref.)

Also available in: Atom PDF