Ruby Issue Tracking System: Issues
https://redmine.ruby-lang.org/
https://redmine.ruby-lang.org/favicon.ico?1711330511
2017-08-22T08:18:28Z
Ruby Issue Tracking System
Redmine
Ruby master - Bug #13835 (Closed): Using 'open-uri' with 'tempfile' causes an exception
https://redmine.ruby-lang.org/issues/13835
2017-08-22T08:18:28Z
thorsteneckel (Thorsten Eckel)
<p>Hi there,</p>
<p>try this in your current ruby env:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">require</span> <span class="s1">'tempfile'</span>
<span class="nb">require</span> <span class="s1">'open-uri'</span>
<span class="n">temp_file</span> <span class="o">=</span> <span class="no">Tempfile</span><span class="p">.</span><span class="nf">new</span>
<span class="nb">open</span><span class="p">(</span><span class="n">temp_file</span><span class="p">,</span> <span class="s1">'a'</span><span class="p">)</span>
</code></pre>
<p>Get this:</p>
<pre><code>/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>'
</code></pre>
<p>I created the pull request <a href="https://github.com/ruby/ruby/pull/1680" class="external">https://github.com/ruby/ruby/pull/1680</a> as a proposal. It's based on the previous pull request <a href="https://github.com/ruby/ruby/pull/1675" class="external">https://github.com/ruby/ruby/pull/1675</a> and feedback of <a class="user active user-mention" href="https://redmine.ruby-lang.org/users/4">@nobu (Nobuyoshi Nakada)</a> .</p>
<p>Greetings.</p>