summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorayumin <ayumin@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-07 05:04:02 +0000
committerayumin <ayumin@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-07 05:04:02 +0000
commitbdb4fa708465479259cbe2f0215376f6252b7773 (patch)
treeb8626e80dc54bb6067ac634a3c3f554e50c84243 /lib
parentb460f8849b6123a1ae1655da62ef9fda1619b891 (diff)
merge revision(s) 34252:
* lib/tempfile.rb (Tempfile#_close): clear @tempfile and @data[1] even when exception is raised at @tempfile.close. [ruby-dev:45113] * lib/tempfile.rb (Tempfile#unlink): fix a typo. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/tempfile.rb11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index 22401b030c..8a517d6746 100644
--- a/lib/tempfile.rb
+++ b/lib/tempfile.rb
@@ -162,9 +162,12 @@ class Tempfile < DelegateClass(File)
end
def _close # :nodoc:
- @tmpfile.close if @tmpfile
- @tmpfile = nil
- @data[1] = nil if @data
+ begin
+ @tmpfile.close if @tmpfile
+ ensure
+ @tmpfile = nil
+ @data[1] = nil if @data
+ end
end
protected :_close
@@ -231,7 +234,7 @@ class Tempfile < DelegateClass(File)
File.unlink(@tmpname)
end
# remove tmpname from remover
- @data[0] = @data[2] = nil
+ @data[0] = @data[1] = nil
@tmpname = nil
rescue Errno::EACCES
# may not be able to unlink on Windows; just ignore