[#79440] [Ruby trunk Bug#13188] Reinitialize Ruby VM. — shyouhei@...
Issue #13188 has been updated by Shyouhei Urabe.
6 messages
2017/02/06
[#79441] Re: [Ruby trunk Bug#13188] Reinitialize Ruby VM.
— SASADA Koichi <ko1@...>
2017/02/06
On 2017/02/06 10:10, shyouhei@ruby-lang.org wrote:
[#79532] Immutable Strings vs Symbols — Daniel Ferreira <subtileos@...>
Hi,
15 messages
2017/02/15
[#79541] Re: Immutable Strings vs Symbols
— Rodrigo Rosenfeld Rosas <rr.rosas@...>
2017/02/15
Em 15-02-2017 05:05, Daniel Ferreira escreveu:
[#79543] Re: Immutable Strings vs Symbols
— Daniel Ferreira <subtileos@...>
2017/02/16
Hi Rodrigo,
[#79560] Re: Immutable Strings vs Symbols
— Rodrigo Rosenfeld Rosas <rr.rosas@...>
2017/02/16
Em 15-02-2017 22:39, Daniel Ferreira escreveu:
[ruby-core:79465] [Ruby trunk Bug#13198][Assigned] Tempfile#size is nil when nothing is written, expected 0
From:
nobu@...
Date:
2017-02-07 07:55:36 UTC
List:
ruby-core #79465
Issue #13198 has been updated by Nobuyoshi Nakada.
Status changed from Open to Assigned
Assignee set to Masaki Matsushita
Backport changed from 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN to 2.2: DONTNEED, 2.3: REQUIRED, 2.4: REQUIRED
It is because `Fie.size?` is used instead of `File.size`, since r50682.
I suspect that it would be a typo and unintentional.
```diff
diff --git i/lib/tempfile.rb w/lib/tempfile.rb
index d068dd603c..b36c6638b6 100644
--- i/lib/tempfile.rb
+++ w/lib/tempfile.rb
@@ -227,7 +227,7 @@
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
diff --git i/test/test_tempfile.rb w/test/test_tempfile.rb
index 7f7f75c7db..a2b272747e 100644
--- i/test/test_tempfile.rb
+++ w/test/test_tempfile.rb
@@ -247,6 +247,13 @@
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 = []
```
----------------------------------------
Bug #13198: Tempfile#size is nil when nothing is written, expected 0
https://bugs.ruby-lang.org/issues/13198#change-62895
* Author: Kyle Drake
* Status: Assigned
* Priority: Normal
* Assignee: Masaki Matsushita
* Target version:
* ruby -v:
* Backport: 2.2: DONTNEED, 2.3: REQUIRED, 2.4: REQUIRED
----------------------------------------
~~~ ruby
require 'tempfile'
tmp = Tempfile.new
tmp.write ''
tmp.close
tmp.size # => nil
File.size(tmp.path) # => 0
~~~
I'm not sure if this is actually a bug, but this behavior really surprised me. I think it would be better to return 0 in this scenario instead of nil, which would match the behavior of File.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>