From: glass.saga@... Date: 2015-06-15T01:22:10+00:00 Subject: [ruby-core:69589] [Ruby trunk - Feature #7148] Improved Tempfile w/o DelegateClass Issue #7148 has been updated by Masaki Matsushita. Assignee changed from Yukihiro Matsumoto to Masaki Matsushita ---------------------------------------- Feature #7148: Improved Tempfile w/o DelegateClass https://bugs.ruby-lang.org/issues/7148#change-52931 * Author: Masaki Matsushita * Status: Assigned * Priority: Low * Assignee: Masaki Matsushita ---------------------------------------- I propose improved `Tempfile` without `DelegateClass()`. Present `Tempfile` has following problems. 1. confusing inspect ~~~ruby t = Tempfile.new("foo") #=> # t.is_a? File #=> false ~~~ 2. `#dup` doesn't duplicate `IO` ~~~ruby t = Tempfile.new("foo") t.dup.close t.read #=> IOError: closed stream ~~~ 3. finalizer performs unlink even when it has been duplicated ~~~ruby t = Tempfile.new("foo") path = t.path #=> "/tmp/foo20121012-7533-1q537gq" File.exist? path #=> true tt = t.dup t = nil GC.start File.exist? path #=> false ~~~ I think these problems caused by using `DelegateClass()`. Therefore, I made a patch to resolve the problems. The patched Tempfile class is a subclass of File. ---Files-------------------------------- patch.diff (3.52 KB) -- https://bugs.ruby-lang.org/