[前][次][番号順一覧][スレッド一覧]

ruby-changes:31150

From: nagachika <ko1@a...>
Date: Thu, 10 Oct 2013 01:11:24 +0900 (JST)
Subject: [ruby-changes:31150] nagachika:r43229 (ruby_2_0_0): merge revision(s) 43110, 43155: [Backport #8768]

nagachika	2013-10-10 01:11:16 +0900 (Thu, 10 Oct 2013)

  New Revision: 43229

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43229

  Log:
    merge revision(s) 43110,43155: [Backport #8768]
    
    * lib/tempfile.rb (Tempfile#unlink): finalizer is no longer needed
      after unlinking.  patched by by normalperson (Eric Wong) at
      [ruby-core:56521] [Bug #8768]

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/lib/tempfile.rb
    branches/ruby_2_0_0/test/test_tempfile.rb
    branches/ruby_2_0_0/version.h
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 43228)
+++ ruby_2_0_0/ChangeLog	(revision 43229)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Thu Oct 10 01:07:37 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* lib/tempfile.rb (Tempfile#unlink): finalizer is no longer needed
+	  after unlinking.  patched by by normalperson (Eric Wong) at
+	  [ruby-core:56521] [Bug #8768]
+
 Thu Oct 10 00:58:39 2013  Benoit Daloze  <eregontp@g...>
 
 	* test/ruby/test_array.rb (test_count): add a test case for #count
Index: ruby_2_0_0/lib/tempfile.rb
===================================================================
--- ruby_2_0_0/lib/tempfile.rb	(revision 43228)
+++ ruby_2_0_0/lib/tempfile.rb	(revision 43229)
@@ -190,7 +190,6 @@ class Tempfile < DelegateClass(File) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/tempfile.rb#L190
   def close!
     _close
     unlink
-    ObjectSpace.undefine_finalizer(self)
   end
 
   # Unlinks (deletes) the file from the filesystem. One should always unlink
@@ -238,6 +237,7 @@ class Tempfile < DelegateClass(File) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/tempfile.rb#L237
     # remove tmpname from remover
     @data[0] = @data[1] = nil
     @tmpname = nil
+    ObjectSpace.undefine_finalizer(self)
   end
   alias delete unlink
 
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 43228)
+++ ruby_2_0_0/version.h	(revision 43229)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2013-10-10"
-#define RUBY_PATCHLEVEL 332
+#define RUBY_PATCHLEVEL 333
 
 #define RUBY_RELEASE_YEAR 2013
 #define RUBY_RELEASE_MONTH 10
Index: ruby_2_0_0/test/test_tempfile.rb
===================================================================
--- ruby_2_0_0/test/test_tempfile.rb	(revision 43228)
+++ ruby_2_0_0/test/test_tempfile.rb	(revision 43229)
@@ -206,6 +206,21 @@ puts Tempfile.new('foo').path https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/test_tempfile.rb#L206
     end
   end
 
+  def test_tempfile_finalizer_does_not_run_if_unlinked
+    bug8768 = '[ruby-core:56521] [Bug #8768]'
+    args = %w(--disable-gems -rtempfile)
+    assert_in_out_err(args, <<-'EOS') do |(filename), (error)|
+      tmp = Tempfile.new('foo')
+      puts tmp.path
+      tmp.close
+      tmp.unlink
+      $DEBUG = true
+      EOS
+      assert_file.not_exist?(filename)
+      assert_nil(error, "#{bug8768} we used to get a confusing 'removing ...done' here")
+    end
+  end
+
   def test_size_flushes_buffer_before_determining_file_size
     t = tempfile("foo")
     t.write("hello")

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r43110,43155


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]