tempfile.rb: do not call File.identical? on closed stream

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-05-19 09:36:34 +00:00
parent 940f32eb5d
commit a6df192ded

View File

@ -334,10 +334,12 @@ def Tempfile.create(basename="", tmpdir=nil, mode: 0, **options)
begin begin
yield tmpfile yield tmpfile
ensure ensure
if File.identical?(tmpfile, tmpfile.path) unless tmpfile.closed?
unlinked = File.unlink tmpfile.path rescue nil if File.identical?(tmpfile, tmpfile.path)
unlinked = File.unlink tmpfile.path rescue nil
end
tmpfile.close
end end
tmpfile.close
unless unlinked unless unlinked
begin begin
File.unlink tmpfile.path File.unlink tmpfile.path