Project

General

Profile

Actions

Bug #7027

closed

Tempfile#inspect is Confusing

Added by Glass_saga (Masaki Matsushita) over 12 years ago. Updated about 12 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 2.0.0dev (2012-09-15 trunk 36975) [x86_64-linux]
Backport:
[ruby-core:47544]

Description

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 = Tempfile.new("hoge")
=> #File:/tmp/hoge20120916-12354-uontdm
irb(main):002:0> t.is_a? File
=> false
irb(main):003:0>

see also (Japanese): http://r7kamura.hatenablog.com/entry/2012/09/05/194630


Files

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

Updated by Hanmac (Hans Mackowiak) over 12 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

Updated by headius (Charles Nutter) over 12 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 = Tempfile.new('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]

Updated by mame (Yusuke Endoh) about 12 years ago

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

Glass_saga,

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

--
Yusuke Endoh

Updated by Glass_saga (Masaki Matsushita) about 12 years ago

  • Status changed from Assigned to Closed

I have commited in r37492.

Updated by nagachika (Tomoyuki Chikanaga) about 12 years ago

  • r37493 (for ChangeLog ML, ticket ref.)
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0