ruby-changes:62757
From: Benoit <ko1@a...>
Date: Sat, 29 Aug 2020 19:31:03 +0900 (JST)
Subject: [ruby-changes:62757] 3beecafc2c (master): Fix usages of Tempfile.open(&block) that expected the file to still be there after the block
https://git.ruby-lang.org/ruby.git/commit/?id=3beecafc2c From 3beecafc2cae86290a191c1e841be13f5b08795d Mon Sep 17 00:00:00 2001 From: Benoit Daloze <eregontp@g...> Date: Sat, 29 Aug 2020 12:23:31 +0200 Subject: Fix usages of Tempfile.open(&block) that expected the file to still be there after the block diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index b4d2b45..6826d58 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -2079,12 +2079,14 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L2079 end private def vi_histedit(key) - path = Tempfile.open { |fp| + Tempfile.open { |fp| fp.write @line - fp.path + path = fp.path + fp.close + + system("#{ENV['EDITOR']} #{path}") + @line = File.read(path) } - system("#{ENV['EDITOR']} #{path}") - @line = File.read(path) finish end diff --git a/test/openssl/test_x509store.rb b/test/openssl/test_x509store.rb index 1cbc73d..e1898d6 100644 --- a/test/openssl/test_x509store.rb +++ b/test/openssl/test_x509store.rb @@ -33,20 +33,21 @@ class OpenSSL::TestX509Store < OpenSSL::TestCase https://github.com/ruby/ruby/blob/trunk/test/openssl/test_x509store.rb#L33 ] cert1 = issue_cert(@ca1, @rsa1024, 1, ca_exts, nil, nil) cert2 = issue_cert(@ca2, @rsa2048, 1, ca_exts, nil, nil) - tmpfile = Tempfile.open { |f| f << cert1.to_pem << cert2.to_pem; f } - - store = OpenSSL::X509::Store.new - assert_equal false, store.verify(cert1) - assert_equal false, store.verify(cert2) - store.add_file(tmpfile.path) - assert_equal true, store.verify(cert1) - assert_equal true, store.verify(cert2) - - # OpenSSL < 1.1.1 leaks an error on a duplicate certificate - assert_nothing_raised { store.add_file(tmpfile.path) } - assert_equal [], OpenSSL.errors - ensure - tmpfile and tmpfile.close! + Tempfile.open { |tmpfile| + tmpfile << cert1.to_pem << cert2.to_pem + tmpfile.close + + store = OpenSSL::X509::Store.new + assert_equal false, store.verify(cert1) + assert_equal false, store.verify(cert2) + store.add_file(tmpfile.path) + assert_equal true, store.verify(cert1) + assert_equal true, store.verify(cert2) + + # OpenSSL < 1.1.1 leaks an error on a duplicate certificate + assert_nothing_raised { store.add_file(tmpfile.path) } + assert_equal [], OpenSSL.errors + } end def test_verify -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/