[ruby-core:93938] [Ruby master Bug#13835] Using 'open-uri' with 'tempfile' causes an exception

From: merch-redmine@...
Date: 2019-07-26 21:45:16 UTC
List: ruby-core #93938
Issue #13835 has been updated by jeremyevans0 (Jeremy Evans).

Status changed from Open to Closed

This issue no longer occurs in the master branch, probably due to commit:05aac90a1bcfeb180f5e78ea8b00a4d1b04d5eed.  That commit changed the behavior so that `open` is not called on the first argument to `Kernel#open` if the object responds to `to_path`.  This was done to avoid an warning when using `Kernel#open` with `Pathname` instances, but it looks like it fixed this issue as well.

----------------------------------------
Bug #13835: Using 'open-uri' with 'tempfile' causes an exception
https://bugs.ruby-lang.org/issues/13835#change-80107

* Author: thorsteneckel (Thorsten Eckel)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
Hi there,

try this in your current ruby env:

~~~ ruby
require 'tempfile'
require 'open-uri'

temp_file = Tempfile.new
open(temp_file, 'a')
~~~

Get this:

~~~
/Users/~/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tempfile.rb:142:in `open': wrong number of arguments (given 1, expected 0) (ArgumentError)
  from /Users/~/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/open-uri.rb:31:in `open'
  from debug.rb:5:in `<main>'
~~~

I created the pull request https://github.com/ruby/ruby/pull/1680 as a proposal. It's based on the previous pull request https://github.com/ruby/ruby/pull/1675 and feedback of @nobu .

Greetings.



-- 
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>

In This Thread

Prev Next