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

ruby-changes:45942

From: naruse <ko1@a...>
Date: Sat, 18 Mar 2017 21:02:32 +0900 (JST)
Subject: [ruby-changes:45942] naruse:r58013 (ruby_2_4): merge revision(s) 57972: [Backport #13198]

naruse	2017-03-18 21:02:27 +0900 (Sat, 18 Mar 2017)

  New Revision: 58013

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58013

  Log:
    merge revision(s) 57972: [Backport #13198]
    
    Fix bug of Tempfile#size if nothing is written [Bug #13198]
    
    * lib/tempfile.rb (Tempfile#size): Fix its behavior when nothing
      is written. Tempfile#size should return 0 in this case.
      The patch is from nobu <nobu@r...>.

  Modified directories:
    branches/ruby_2_4/
  Modified files:
    branches/ruby_2_4/lib/tempfile.rb
    branches/ruby_2_4/test/test_tempfile.rb
    branches/ruby_2_4/version.h
Index: ruby_2_4/lib/tempfile.rb
===================================================================
--- ruby_2_4/lib/tempfile.rb	(revision 58012)
+++ ruby_2_4/lib/tempfile.rb	(revision 58013)
@@ -227,7 +227,7 @@ class Tempfile < DelegateClass(File) https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/tempfile.rb#L227
     if !@tmpfile.closed?
       @tmpfile.size # File#size calls rb_io_flush_raw()
     else
-      File.size?(@tmpfile.path)
+      File.size(@tmpfile.path)
     end
   end
   alias length size
Index: ruby_2_4/version.h
===================================================================
--- ruby_2_4/version.h	(revision 58012)
+++ ruby_2_4/version.h	(revision 58013)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1
 #define RUBY_VERSION "2.4.0"
-#define RUBY_RELEASE_DATE "2017-03-17"
-#define RUBY_PATCHLEVEL 105
+#define RUBY_RELEASE_DATE "2017-03-18"
+#define RUBY_PATCHLEVEL 106
 
 #define RUBY_RELEASE_YEAR 2017
 #define RUBY_RELEASE_MONTH 3
-#define RUBY_RELEASE_DAY 17
+#define RUBY_RELEASE_DAY 18
 
 #include "ruby/version.h"
 
Index: ruby_2_4/test/test_tempfile.rb
===================================================================
--- ruby_2_4/test/test_tempfile.rb	(revision 58012)
+++ ruby_2_4/test/test_tempfile.rb	(revision 58013)
@@ -247,6 +247,13 @@ puts Tempfile.new('foo').path https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/test_tempfile.rb#L247
     assert_equal 5, t.size
   end
 
+  def test_size_on_empty_file
+    t = tempfile("foo")
+    t.write("")
+    t.close
+    assert_equal 0, t.size
+  end
+
   def test_concurrency
     threads = []
     tempfiles = []

Property changes on: ruby_2_4
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r57972


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

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