summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-09 15:46:25 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-09 15:46:25 +0000
commitc572ed2d25c290de7f518278dcae29d375c49d2d (patch)
tree7e70236889f2cd90b777ec8b580b8ad99662e8d0
parent896844a0cc9da1516a05b174158567d391f33288 (diff)
* lib/tempfile.rb (Tempfile#_close): clear @tempfile and @data[1] even
when an 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/trunk@34252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--lib/tempfile.rb11
2 files changed, 14 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index b6e5d64413..dfb5b34991 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Tue Jan 10 00:41:28 2012 CHIKANAGA Tomoyuki <nagachika00@gmail.com>
+
+ * 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.
+
Tue Jan 10 00:32:17 2012 CHIKANAGA Tomoyuki <nagachika00@gmail.com>
* gc.c (run_finalizer): clear rb_thread_t::errinfo when ignore
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index 3321116792..5e860db095 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