Ruby Issue Tracking System: Issueshttps://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112017-01-05T19:34:49ZRuby Issue Tracking System
Redmine Ruby master - Bug #13107 (Closed): def_delegators causes random errors in MRI 2.4.0https://bugs.ruby-lang.org/issues/131072017-01-05T19:34:49Ztwalpole@gmail.com (Thomas Walpole)twalpole@gmail.com
<p>In the Capybara project we use the rack_test gem which uses <code>def_delegators</code> to forward <code>flast_reponse</code> to <code>@rack_mock_session</code> - <a href="https://github.com/brynary/rack-test/blob/master/lib/rack/test.rb#L29" class="external">https://github.com/brynary/rack-test/blob/master/lib/rack/test.rb#L29</a></p>
<p>When running the Capybara test test suite calling last_reponse on a rack_test Session object will sporadically result in a <code>TypeError</code> from forwardable.rb</p>
<pre><code>TypeError:
wrong argument type Integer (expected Proc)
</code></pre>
<p>Patching around the delegator with</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">class</span> <span class="nc">Rack::Test::Session</span>
<span class="k">def</span> <span class="nf">last_response</span>
<span class="vi">@rack_mock_session</span><span class="p">.</span><span class="nf">last_response</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<p>stops the error from occurring, so it appears that something <code>def_delegators</code> is doing is causing problems. Unfortunately I have not yet been able to establish exactly what causes the issues to produce a simple test case.</p> Ruby master - Bug #11721 (Closed): String used as IO object buffer unexpectedly frozen if #to_sym...https://bugs.ruby-lang.org/issues/117212015-11-20T17:33:03Ztwalpole@gmail.com (Thomas Walpole)twalpole@gmail.com
<p>A string with forced encoding used a buffer for reading from a File becomes frozen unexpectedly if #to_sym is called on it</p>
<p>file = File.open('some_file')<br>
str = ""<br>
str.force_encoding(Encoding::US_ASCII)<br>
str.frozen? # => false<br>
file.read(2,str)<br>
str.frozen? # => false<br>
str.to_sym<br>
str.frozen? # => true</p>
<p>If the force_encoding is skipped str doesn't become frozen, same with reading from the file.</p>