[#18121] [Ruby 1.8.7 - Bug #405] (Open) ssl.rb:31: [BUG] Bus Error — Anonymous <redmine@...>

Issue #405 has been reported by Anonymous.

14 messages 2008/08/04

[#18130] Re: New array methods cycle, choice, shuffle (plus bug in cycle) — Brian Candler <B.Candler@...>

> Seriously though... Array.first is a noun.

10 messages 2008/08/05

[#18319] NEW Command: absolute_path() -- — "C.E. Thornton" <admin@...>

Core,

14 messages 2008/08/16
[#18321] Re: NEW Command: absolute_path() -- — Yukihiro Matsumoto <matz@...> 2008/08/18

Hi,

[#18381] [Bug #496] DRb.start_service(nil) is very slow — Hongli Lai <redmine@...>

Bug #496: DRb.start_service(nil) is very slow

11 messages 2008/08/25

[ruby-core:18394] [Bug #504] Tempfile.open should return the new tempfile rather than nil

From: Tyler Rick <redmine@...>
Date: 2008-08-27 08:48:49 UTC
List: ruby-core #18394
Bug #504: Tempfile.open should return the new tempfile rather than nil
http://redmine.ruby-lang.org/issues/show/504

Author: Tyler Rick
Status: Open, Priority: Normal

It seems like you ought to be able to do this
  f = Tempfile.open("foo") do |f|
    f.print("foo\n")
  end
  p f.path

but curretnly Tempfile.open returns nil. 

I propose the following patch:

--- /usr/lib/ruby/1.9.0/tempfile.old.rb	2008-08-27 01:50:02.000000000 -0700
+++ /usr/lib/ruby/1.9.0/tempfile.rb	2008-08-27 01:51:03.000000000 -0700
@@ -182,15 +182,15 @@
       tempfile = new(*args)
 
       if block_given?
-	begin
-	  yield(tempfile)
-	ensure
-	  tempfile.close
-	end
+        begin
+          yield(tempfile)
+        ensure
+          tempfile.close
+        end
 
-	nil
+        tempfile
       else
-	tempfile
+        tempfile
       end
     end
   end
@@ -204,5 +204,12 @@
   f.open
   p f.gets # => "foo\n"
   f.close!
-end
 
+  f = Tempfile.open("foo") do |f|
+    f.print("foo\n")
+  end
+  p f.path # => "/tmp/foo20080827-5200-7awus9-0"
+  f.open
+  p f.gets # => "foo\n"
+  f.close!
+end


----------------------------------------
http://redmine.ruby-lang.org

In This Thread

Prev Next