1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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@ruby-lang.org>.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@58013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2017-03-18 12:02:27 +00:00
parent 147107ce36
commit 8be9bd482e
3 changed files with 11 additions and 4 deletions

View file

@ -227,7 +227,7 @@ class Tempfile < DelegateClass(File)
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

View file

@ -247,6 +247,13 @@ puts Tempfile.new('foo').path
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 = []

View file

@ -1,10 +1,10 @@
#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"