[ruby-core:80384] [Ruby trunk Bug#13198] Tempfile#size is nil when nothing is written, expected 0

From: nagachika00@...
Date: 2017-03-27 14:47:45 UTC
List: ruby-core #80384
Issue #13198 has been updated by nagachika (Tomoyuki Chikanaga).

Backport changed from 2.2: DONTNEED, 2.3: REQUIRED, 2.4: DONE to 2.2: DONTNEED, 2.3: DONE, 2.4: DONE

ruby_2_3 r58154 merged revision(s) 57972.

----------------------------------------
Bug #13198: Tempfile#size is nil when nothing is written, expected 0
https://bugs.ruby-lang.org/issues/13198#change-63868

* Author: kyledrake (Kyle Drake)
* Status: Closed
* Priority: Normal
* Assignee: Glass_saga (Masaki Matsushita)
* Target version: 
* ruby -v: 
* Backport: 2.2: DONTNEED, 2.3: DONE, 2.4: DONE
----------------------------------------
~~~ 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:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next