Ruby Issue Tracking System: Issueshttps://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112014-12-23T20:32:36ZRuby Issue Tracking System
Redmine Ruby master - Bug #10638 (Closed): Keyword Hash processing is inconsistenthttps://redmine.ruby-lang.org/issues/106382014-12-23T20:32:36Zbrixen (Brian Shirai)brixen@gmail.com
<p>An empty Hash passed to a method taking a keyword rest argument is not dup'd. A modification to the keyword rest Hash in the method modifies the object passed to the method.</p>
<p>This behavior differs from passing a non-empty Hash.</p>
<p><a href="https://gist.github.com/brixen/fbd4a1cebb23ef6b4d85" class="external">https://gist.github.com/brixen/fbd4a1cebb23ef6b4d85</a></p> Ruby master - Bug #10016 (Closed): Destructuring block arguments with a Hashable last elementhttps://redmine.ruby-lang.org/issues/100162014-07-08T21:55:49Zbrixen (Brian Shirai)brixen@gmail.com
<p>The following code:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="c1"># destructure_bug.rb</span>
<span class="k">def</span> <span class="nf">m</span>
<span class="n">x</span> <span class="o">=</span> <span class="no">Object</span><span class="p">.</span><span class="nf">new</span>
<span class="k">def</span> <span class="nc">x</span><span class="o">.</span><span class="nf">to_hash</span><span class="p">()</span> <span class="p">{</span><span class="ss">x: </span><span class="mi">9</span><span class="p">}</span> <span class="k">end</span>
<span class="k">yield</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="n">x</span><span class="p">]</span>
<span class="k">end</span>
<span class="nb">p</span> <span class="n">m</span> <span class="p">{</span> <span class="o">|</span><span class="n">a</span><span class="p">,</span> <span class="o">*</span><span class="n">b</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="o">**</span><span class="n">k</span><span class="o">|</span> <span class="p">[</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="n">k</span><span class="p">]</span> <span class="p">}</span>
</code></pre>
<p>gives:</p>
<pre><code>$ ruby -v destructure_bug.rb
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
[#<Object:0x007fc5fb212870>, [nil], 1, {:x=>9}]
$ ruby -v destructure_bug.rb
ruby 2.2.0dev (2014-06-05 trunk 46353) [x86_64-darwin13]
[#<Object:0x007f88c206c2a8>, [nil], 1, {:x=>9}]
</code></pre>
<p>I would expect: <code>[1, [2], 3, {:x=>9}]</code></p>
<p>Is this a bug?</p> Ruby master - Bug #9898 (Closed): Keyword argument odditieshttps://redmine.ruby-lang.org/issues/98982014-06-03T15:48:18Zbrixen (Brian Shirai)brixen@gmail.com
<p>Case 1: If a method takes a single argument, and the method is called with a keyword splat, the method receives the passed object, not the result of calling <code>#to_hash</code> on the object:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="c1"># kw1.rb</span>
<span class="k">def</span> <span class="nf">m</span><span class="p">(</span><span class="n">a</span><span class="p">)</span> <span class="n">a</span> <span class="k">end</span>
<span class="n">o</span> <span class="o">=</span> <span class="no">Object</span><span class="p">.</span><span class="nf">new</span>
<span class="k">def</span> <span class="nc">o</span><span class="o">.</span><span class="nf">to_hash</span><span class="p">()</span> <span class="nb">puts</span> <span class="s2">"to_hash"</span><span class="p">;</span> <span class="p">{</span> <span class="ss">a: </span><span class="mi">1</span> <span class="p">}</span> <span class="k">end</span>
<span class="nb">p</span> <span class="n">m</span><span class="p">(</span><span class="o">**</span><span class="n">o</span><span class="p">)</span>
</code></pre>
<pre><code>$ ruby -v kw1.rb
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
to_hash
#<Object:0x007fdee188ab90>
</code></pre>
<p>Would someone please explain why the result of <code>#to_hash</code> in not passed to the method?</p>
<p>Case 2: If the method takes a keyword argument, <code>#to_hash</code> is called at the send site and at the receiver:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="c1"># kw2.rb</span>
<span class="k">def</span> <span class="nf">mk</span><span class="p">(</span><span class="n">a</span><span class="p">:)</span> <span class="n">a</span> <span class="k">end</span>
<span class="n">o</span> <span class="o">=</span> <span class="no">Object</span><span class="p">.</span><span class="nf">new</span>
<span class="k">def</span> <span class="nc">o</span><span class="o">.</span><span class="nf">to_hash</span><span class="p">()</span> <span class="nb">puts</span> <span class="s2">"to_hash"</span><span class="p">;</span> <span class="p">{</span> <span class="ss">a: </span><span class="mi">1</span> <span class="p">}</span> <span class="k">end</span>
<span class="nb">p</span> <span class="n">mk</span><span class="p">(</span><span class="o">**</span><span class="n">o</span><span class="p">)</span>
</code></pre>
<pre><code>$ ruby -v kw2.rb
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
to_hash
to_hash
1
</code></pre>
<p>Would someone please explain why <code>#to_hash</code> is called at both the send site and at the receiver?</p> Ruby master - Bug #9810 (Closed): Numeric#step behavior with mixed Float, String arguments incons...https://redmine.ruby-lang.org/issues/98102014-05-06T17:25:57Zbrixen (Brian Shirai)brixen@gmail.com
<p>The <code>Numeric#step</code> documentation states:</p>
<p>"If any of the arguments are floating point numbers, all are converted to floats..."</p>
<p><a href="https://github.com/ruby/ruby/blob/trunk/numeric.c#L1921" class="external">https://github.com/ruby/ruby/blob/trunk/numeric.c#L1921</a></p>
<p>Is the following code intended to be described by that documentation?</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="mf">1.1</span><span class="p">.</span><span class="nf">step</span><span class="p">(</span><span class="mf">5.1</span><span class="p">,</span> <span class="s2">"1"</span><span class="p">)</span> <span class="p">{}</span>
</code></pre>
<p>Previously (eg 2.0.0) resulted in a <code>TypeError</code>:</p>
<pre><code>$ ruby -v -e 'p 1.1.step(5.1, "1") {}'
ruby 2.0.0p247 (2013-06-27) [x86_64-darwin13.0.1]
-e:1:in `step': no implicit conversion to float from string (TypeError)
from -e:1:in `<main>'
</code></pre>
<p>In 2.1.1, at least, an <code>ArgumentError</code> is raised:</p>
<pre><code>$ ruby -v -e 'p 1.1.step(5.1, "1") {}'
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0]
-e:1:in `>': comparison of String with 0 failed (ArgumentError)
from -e:1:in `step'
from -e:1:in `<main>'
</code></pre>
<p>What's the intended behavior?</p> Ruby master - Bug #8945 (Closed): Unmarshaling an Array containing a Bignum from a tainted String...https://redmine.ruby-lang.org/issues/89452013-09-24T13:07:54Zbrixen (Brian Shirai)brixen@gmail.com
<p>In 2.1, Symbol, Fixnum, Bignum, and Float (at least) have been changed to frozen by default. Consequently, calling #taint on an instance of those classes raises a RuntimeError because a frozen object cannot be modified to be tainted. However:</p>
<p>sasha:rbx brian$ ruby -v<br>
ruby 2.1.0dev (2013-09-24 trunk 43025) [x86_64-darwin13.0.0]<br>
sasha:rbx brian$ irb<br>
irb(main):001:0> a = 0xffff_ffff_ffff_ffff<br>
=> 18446744073709551615<br>
irb(main):002:0> a.class<br>
=> Bignum<br>
irb(main):003:0> a.frozen?<br>
=> true<br>
irb(main):004:0> a.tainted?<br>
=> false<br>
irb(main):005:0> str = Marshal.dump([a]).taint<br>
=> "\x04\b[\x06l+\t\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"<br>
irb(main):006:0> str.tainted?<br>
=> true<br>
irb(main):007:0> aa = Marshal.load(str)<br>
=> [18446744073709551615]<br>
irb(main):008:0> aa.first.class<br>
=> Bignum<br>
irb(main):009:0> aa.first.frozen?<br>
=> true<br>
irb(main):010:0> aa.first.tainted?<br>
=> true<br>
irb(main):011:0></p>
<p>The behavior above is inconsistent with the results of performing the same operations on instances of Symbol, Fixnum, Float. For example:</p>
<p>irb(main):014:0> :a.frozen?<br>
=> true<br>
irb(main):015:0> :a.tainted?<br>
=> false<br>
irb(main):016:0> str = Marshal.dump([:a]).taint<br>
=> "\x04\b[\x06:\x06a"<br>
irb(main):017:0> aa = Marshal.load(str)<br>
=> [:a]<br>
irb(main):018:0> aa.tainted?<br>
=> true<br>
irb(main):019:0> aa.first.frozen?<br>
=> true<br>
irb(main):020:0> aa.first.tainted?<br>
=> false</p> Ruby master - Bug #7964 (Assigned): Writing an ASCII-8BIT String to a StringIO created from a UTF...https://redmine.ruby-lang.org/issues/79642013-02-26T16:32:50Zbrixen (Brian Shirai)brixen@gmail.com
<p>=begin<br>
In the following script, an ASCII-8BIT String is written to a StringIO created with a UTF-8 String without error. However, a << b or a + b will raise an exception, as will writing an ASCII-8BIT String to a File with UTF-8 external encoding.</p>
<ul>
<li>
<p>$ cat file_enc.rb</p>
<a name="encoding-utf-8"></a>
<h1 >encoding: utf-8<a href="#encoding-utf-8" class="wiki-anchor">¶</a></h1>
<p>require 'stringio'</p>
<p>a = "On a very cold morning, it was -8°F."<br>
b = a.dup.force_encoding "ascii-8bit"</p>
<p>io = StringIO.new a<br>
io.write(b)<br>
p io.string.encoding</p>
<p>File.open "data.txt", "w:utf-8" do |f|<br>
f.write a<br>
f.write b<br>
end</p>
</li>
<li>
<p>$ ruby2.0 -v file_enc.rb<br>
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin10.8.0]<br>
#<a href="Encoding:UTF-8" class="external">Encoding:UTF-8</a><br>
file_enc.rb:13:in <code>write': "\xC2" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError) from file_enc.rb:13:in </code>block in '<br>
from file_enc.rb:11:in <code>open' from file_enc.rb:11:in </code>'</p>
</li>
<li>
<p>$ ruby1.9.3 -v file_enc.rb<br>
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin10.8.0]<br>
#<a href="Encoding:UTF-8" class="external">Encoding:UTF-8</a><br>
file_enc.rb:13:in <code>write': "\xC2" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError) from file_enc.rb:13:in </code>block in '<br>
from file_enc.rb:11:in <code>open' from file_enc.rb:11:in </code>'<br>
=end</p>
</li>
</ul> Ruby master - Bug #7566 (Rejected): Escape (\u{}) forms in Regexp literalshttps://redmine.ruby-lang.org/issues/75662012-12-15T10:06:19Zbrixen (Brian Shirai)brixen@gmail.com
<p>Why are \u{} escape sequences in Regexp literals not converted to bytes like they are in String literals?</p>
<p><a href="https://gist.github.com/4290155" class="external">https://gist.github.com/4290155</a></p>
<p>Thanks,<br>
Brian</p> Ruby master - Feature #7549 (Rejected): A Ruby Design Processhttps://redmine.ruby-lang.org/issues/75492012-12-12T16:45:00Zbrixen (Brian Shirai)brixen@gmail.com
<p>Matz,</p>
<p>At RubyConf 2012, I gave a talk about a design process for Ruby (<a href="http://www.confreaks.com/videos/1278-rubyconf2012-toward-a-design-for-ruby" class="external">http://www.confreaks.com/videos/1278-rubyconf2012-toward-a-design-for-ruby</a>). So far, over 12,000 people have viewed that talk. I think it is reasonable to say that many people are concerned about and interested in a design process for Ruby.</p>
<p>On Monday, we had an IRC meeting of Ruby implementers. Most of the points in my proposal were discussed but I'm concerned that a lot of confusion remains.</p>
<p>I have written a post that describes a Ruby design process and hopefully clarifies points that people found confusing:</p>
<p><a href="http://brixen.io/2012/12/11/a-ruby-design-process" class="external">http://brixen.io/2012/12/11/a-ruby-design-process</a></p>
<p>I would like to propose this process for making changes to Ruby. I am going to put a summary of the process at <a href="http://rubyspec.org/design" class="external">http://rubyspec.org/design</a> and ask for people who support the process to submit their signature. I'd like to request that you consider the response from the community for my proposal.</p>
<p>Thank you,<br>
Brian</p> Ruby master - Bug #7431 (Rejected): Encoding.compatible? results are order-dependent for Strings ...https://redmine.ruby-lang.org/issues/74312012-11-25T12:32:28Zbrixen (Brian Shirai)brixen@gmail.com
<p>Could someone please explain the following?</p>
<p>1.9.3p286 :001 > Encoding.compatible? "euc-jp", "utf-8"<br>
=> #<a href="Encoding:UTF-8" class="external">Encoding:UTF-8</a><br>
1.9.3p286 :002 > Encoding.compatible? "utf-8", "euc-jp"<br>
=> #<a href="Encoding:UTF-8" class="external">Encoding:UTF-8</a><br>
1.9.3p286 :003 > a = "a".force_encoding "utf-8"<br>
=> "a"<br>
1.9.3p286 :004 > b = "b".force_encoding "euc-jp"<br>
=> "b"<br>
1.9.3p286 :005 > Encoding.compatible? a, b<br>
=> #<a href="Encoding:UTF-8" class="external">Encoding:UTF-8</a><br>
1.9.3p286 :006 > Encoding.compatible? b, a<br>
=> #<a href="Encoding:EUC-JP" class="external">Encoding:EUC-JP</a><br>
1.9.3p286 :007 > Encoding.compatible? a, "euc-jp"<br>
=> #<a href="Encoding:UTF-8" class="external">Encoding:UTF-8</a><br>
1.9.3p286 :008 > Encoding.compatible? "euc-jp", a<br>
=> #<a href="Encoding:UTF-8" class="external">Encoding:UTF-8</a><br>
1.9.3p286 :009 > Encoding.compatible? b, "utf-8"<br>
=> #<a href="Encoding:EUC-JP" class="external">Encoding:EUC-JP</a><br>
1.9.3p286 :010 > Encoding.compatible? "utf-8", b<br>
=> #<a href="Encoding:UTF-8" class="external">Encoding:UTF-8</a></p>
<p>Thanks,<br>
Brian</p> Ruby master - Bug #7232 (Closed): StringIO#gets(nil, nil) raises TypeError, IO/File#gets do nothttps://redmine.ruby-lang.org/issues/72322012-10-29T04:07:11Zbrixen (Brian Shirai)brixen@gmail.com
<p>Is this a bug?</p>
<p>sasha:rubinius brian$ irb<br>
1.9.3p286 :001 > require 'stringio'<br>
=> true<br>
1.9.3p286 :002 > s = StringIO.new "abc"<br>
=> #<a href="StringIO:0x000001008b3d90" class="external">StringIO:0x000001008b3d90</a><br>
1.9.3p286 :003 > s.gets nil, nil<br>
TypeError: no implicit conversion from nil to integer<br>
from (irb):3:in <code>gets' from (irb):3 from /Users/brian/.rvm/rubies/ruby-1.9.3-p286/bin/irb:16:in </code>'</p>
<p>sasha:rubinius brian$ irb<br>
1.9.3p286 :001 > f = File.open "foobar.txt"<br>
=> #<a href="File:foobar.txt" class="external">File:foobar.txt</a><br>
1.9.3p286 :002 > io = IO.new f.fileno<br>
=> #<IO:fd 5><br>
1.9.3p286 :003 > io.gets nil, nil<br>
=> "ありがとう\n"<br>
1.9.3p286 :004 > f.rewind<br>
=> 0<br>
1.9.3p286 :005 > f.gets nil, nil<br>
=> "ありがとう\n"</p>
<p>Thanks,<br>
Brian</p> Ruby master - Bug #7231 (Closed): StringIO inconsistently raises IOError or RuntimeError if the s...https://redmine.ruby-lang.org/issues/72312012-10-29T04:00:59Zbrixen (Brian Shirai)brixen@gmail.com
<p>StringIO#ungetc, #ungetbyte raise RuntimeError if the data string is frozen. StringIO#write raises IOError.</p>
<p>Why?</p>
<p>1.9.3p286 :001 > require 'stringio'<br>
=> true<br>
1.9.3p286 :002 > s = StringIO.new x = "abc"<br>
=> #<a href="StringIO:0x00000101020038" class="external">StringIO:0x00000101020038</a><br>
1.9.3p286 :003 > x.freeze<br>
=> "abc"<br>
1.9.3p286 :004 > s.ungetbyte 0x42<br>
RuntimeError: can't modify frozen String<br>
from (irb):4:in <code>ungetbyte' from (irb):4 from /Users/brian/.rvm/rubies/ruby-1.9.3-p286/bin/irb:16:in </code>'<br>
1.9.3p286 :005 > s.ungetc "w"<br>
RuntimeError: can't modify frozen String<br>
from (irb):5:in <code>ungetc' from (irb):5 from /Users/brian/.rvm/rubies/ruby-1.9.3-p286/bin/irb:16:in </code>'<br>
1.9.3p286 :006 > s.write "d"<br>
IOError: not modifiable string<br>
from (irb):6:in <code>write' from (irb):6 from /Users/brian/.rvm/rubies/ruby-1.9.3-p286/bin/irb:16:in </code>'</p>
<p>Thanks,<br>
Brian</p> Ruby master - Feature #7220 (Open): Separate IO#dup, StringIO#initialize_copy from dup(2)https://redmine.ruby-lang.org/issues/72202012-10-27T03:38:14Zbrixen (Brian Shirai)brixen@gmail.com
<p>Calling StringIO#initialize_copy causes the two objects to share the position, and eof status.</p>
<p>Is this a bug?</p>
<p>sasha:rubinius brian$ irb<br>
1.9.3p286 :001 > require 'stringio'<br>
=> true<br>
1.9.3p286 :002 > a = StringIO.new "abcdefuq"<br>
=> #<a href="StringIO:0x00000101016a88" class="external">StringIO:0x00000101016a88</a><br>
1.9.3p286 :003 > b = StringIO.new<br>
=> #<a href="StringIO:0x00000101010728" class="external">StringIO:0x00000101010728</a><br>
1.9.3p286 :004 > b.send :initialize_copy, a<br>
=> #<a href="StringIO:0x00000101010728" class="external">StringIO:0x00000101010728</a><br>
1.9.3p286 :005 > a.pos<br>
=> 0<br>
1.9.3p286 :006 > b.pos<br>
=> 0<br>
1.9.3p286 :007 > b.getc<br>
=> "a"<br>
1.9.3p286 :008 > a.pos<br>
=> 1<br>
1.9.3p286 :009 > a.getc<br>
=> "b"<br>
1.9.3p286 :010 > b.pos<br>
=> 2<br>
1.9.3p286 :011 > b.read<br>
=> "cdefuq"<br>
1.9.3p286 :012 > a.eof?<br>
=> true</p>
<p>Thanks,<br>
Brian</p> Ruby master - Bug #7201 (Rejected): Setting default_external affects STDIN encoding but default_i...https://redmine.ruby-lang.org/issues/72012012-10-21T14:29:56Zbrixen (Brian Shirai)brixen@gmail.com
<p>Changing Encoding.default_external changes STDIN.external_encoding, but changing Encoding.default_internal does not change STDIN.internal_encoding.</p>
<p>STDOUT and STDERR internal/external encodings are not changed in either case and are always nil.</p>
<p>Is this a bug? See the following IRB transcript:</p>
<p>$ irb<br>
1.9.3p286 :001 > Encoding.default_external<br>
=> #<a href="Encoding:UTF-8" class="external">Encoding:UTF-8</a><br>
1.9.3p286 :002 > Encoding.default_internal<br>
=> nil<br>
1.9.3p286 :003 > STDIN.external_encoding<br>
=> #<a href="Encoding:UTF-8" class="external">Encoding:UTF-8</a><br>
1.9.3p286 :004 > STDIN.internal_encoding<br>
=> nil<br>
1.9.3p286 :005 > Encoding.default_external = "euc-jp"<br>
=> "euc-jp"<br>
1.9.3p286 :006 > STDIN.external_encoding<br>
=> #<a href="Encoding:EUC-JP" class="external">Encoding:EUC-JP</a><br>
1.9.3p286 :007 > STDIN.internal_encoding<br>
=> nil<br>
1.9.3p286 :008 > Encoding.default_internal = "iso-8859-1"<br>
=> "iso-8859-1"<br>
1.9.3p286 :009 > STDIN.internal_encoding<br>
=> nil</p>
<p>Thanks,<br>
Brian</p> Ruby master - Bug #7200 (Rejected): Setting external encoding with BOM|https://redmine.ruby-lang.org/issues/72002012-10-21T11:55:22Zbrixen (Brian Shirai)brixen@gmail.com
<p>File.open will accept, for example, :encoding => "bom|utf-16be:euc-jp" or :encoding => "bom|utf-16be". However, :external_encoding => "bom|utf-16be" raises an ArgumentError. Likewise, IO#set_encoding will accept "bom|utf-16be:euc-jp" but raises an ArgumentError if passed "bom|utf-16be", "euc-jp".</p>
<p>It is inconsistent to accept "bom|utf-*" in some cases and not others.</p>
<p>See the following IRB transcript.</p>
<p>$ irb<br>
1.9.3p286 :001 > f = File.open "foo.txt", "r", :encoding => "bom|utf-16be:euc-jp"<br>
=> #<a href="File:foo.txt" class="external">File:foo.txt</a><br>
1.9.3p286 :002 > f.internal_encoding<br>
=> #<a href="Encoding:EUC-JP" class="external">Encoding:EUC-JP</a><br>
1.9.3p286 :003 > f.external_encoding<br>
=> #<a href="Encoding:UTF-16BE" class="external">Encoding:UTF-16BE</a><br>
1.9.3p286 :004 > f.close<br>
=> nil<br>
1.9.3p286 :005 > f = File.open "foo.txt", "r"<br>
=> #<a href="File:foo.txt" class="external">File:foo.txt</a><br>
1.9.3p286 :006 > f.set_encoding "bom|utf-16be:euc-jp"<br>
=> #<a href="File:foo.txt" class="external">File:foo.txt</a><br>
1.9.3p286 :007 > f.internal_encoding<br>
=> #<a href="Encoding:EUC-JP" class="external">Encoding:EUC-JP</a><br>
1.9.3p286 :008 > f.external_encoding<br>
=> #<a href="Encoding:UTF-16BE" class="external">Encoding:UTF-16BE</a><br>
1.9.3p286 :009 > f.close<br>
=> nil<br>
1.9.3p286 :010 > f = File.open "foo.txt", "r"<br>
=> #<a href="File:foo.txt" class="external">File:foo.txt</a><br>
1.9.3p286 :011 > f.set_encoding "bom|utf-16be", "euc-jp"<br>
ArgumentError: unknown encoding name - bom|utf-16be<br>
from (irb):11:in <code>set_encoding' from (irb):11 from /Users/brian/.rvm/rubies/ruby-1.9.3-p286/bin/irb:16:in </code>'<br>
1.9.3p286 :012 > f = File.open "foo.txt", "w", :external_encoding => "bom|utf-16be"<br>
ArgumentError: unknown encoding name - bom|utf-16be<br>
from (irb):12:in <code>initialize' from (irb):12:in </code>open'<br>
from (irb):12<br>
from /Users/brian/.rvm/rubies/ruby-1.9.3-p286/bin/irb:16:in `'<br>
1.9.3p286 :013 > f = File.open "foo.txt", "rb", :encoding => "bom|utf-16be"<br>
=> #<a href="File:foo.txt" class="external">File:foo.txt</a></p>
<p>Thanks,<br>
Brian</p> Ruby master - Bug #6078 (Closed): The name of a module nested in an anonymous module depends on h...https://redmine.ruby-lang.org/issues/60782012-02-25T04:37:26Zbrixen (Brian Shirai)brixen@gmail.com
<p>If a module is nested under an anonymous module, the nested modules name will depend on how the module is created. See below:</p>
<p>$ irb<br>
1.9.3p125 :001 > m = Module.new<br>
=> #<a href="Module:0x000001009e1398" class="external">Module:0x000001009e1398</a><br>
1.9.3p125 :002 > n = Module.new<br>
=> #<a href="Module:0x000001009e1ca8" class="external">Module:0x000001009e1ca8</a><br>
1.9.3p125 :003 > m::N = n<br>
=> #<a href="Module:0x000001009e1ca8" class="external">Module:0x000001009e1ca8</a><br>
1.9.3p125 :004 > m.name<br>
=> nil<br>
1.9.3p125 :005 > n.name<br>
=> nil<br>
1.9.3p125 :006 > m.constants<br>
=> [:N]<br>
1.9.3p125 :007 > module m::O<br>
1.9.3p125 :008?> end<br>
=> nil<br>
1.9.3p125 :009 > m.constants<br>
=> [:N, :O]<br>
1.9.3p125 :010 > m::N.name<br>
=> nil<br>
1.9.3p125 :011 > m::O.name<br>
=> "#<a href="Module:0x000001009e1398" class="external">Module:0x000001009e1398</a>::O"<br>
1.9.3p125 :012 > m.const_get(:N).name<br>
=> nil<br>
1.9.3p125 :013 > m.const_get(:O).name<br>
=> "#<a href="Module:0x000001009e1398" class="external">Module:0x000001009e1398</a>::O"<br>
1.9.3p125 :014 > M = m<br>
=> M<br>
1.9.3p125 :015 > m::N.name<br>
=> "M::N"<br>
1.9.3p125 :016 > m::O.name<br>
=> "#<a href="Module:0x000001009e1398" class="external">Module:0x000001009e1398</a>::O"</p>
<p>Thanks,<br>
Brian</p> Ruby master - Bug #6067 (Closed): Conditional assignment of a nested constant raises a SyntaxErrorhttps://redmine.ruby-lang.org/issues/60672012-02-23T12:02:12Zbrixen (Brian Shirai)brixen@gmail.com
<p>I can conditionally assign a simple constant:</p>
<p>$ ruby -v -e 'p X ||= 1'<br>
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin10.8.0]<br>
1</p>
<p>However, conditional assignment of a nested constant raises a SyntaxError:</p>
<p>$ ruby -v -e 'module A; end; p A::X ||= 1'<br>
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin10.8.0]<br>
-e:1: constant re-assignment</p>
<p>But I can assign the constant unconditionally, of course:</p>
<p>$ ruby -v -e 'module A; end; p A::X = 1'<br>
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin10.8.0]<br>
1</p>
<p>Is this a bug?</p>
<p>Thanks,<br>
Brian</p> Ruby master - Bug #5921 (Closed): SEGV caused by Encoding.compatible? "abc", :abchttps://redmine.ruby-lang.org/issues/59212012-01-21T15:22:10Zbrixen (Brian Shirai)brixen@gmail.com
<p>Calling Encoding.compatible? with a String and Symbol causes a SEGV.</p>
<p>Calling with two Symbols, a Symbol and Regexp, or a String and Regexp works fine.</p>
<p>sasha:source brian$ ruby -v -e 'p Encoding.compatible? "abc", :abc'<br>
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0]<br>
-e:1: [BUG] Segmentation fault</p>
<p>Full report: <a href="https://gist.github.com/1651681" class="external">https://gist.github.com/1651681</a></p>
<p>Thanks,<br>
Brian</p> Ruby master - Bug #5920 (Rejected): Encoding.compatible? gives inconsistent results with String v...https://redmine.ruby-lang.org/issues/59202012-01-21T13:45:17Zbrixen (Brian Shirai)brixen@gmail.com
<p>Is this a bug? If I pass two strings that have the same encodings as the Encoding instances I pass directly, I get different results.</p>
<p>$ irb<br>
ruby-1.9.3-p0 :001 > Encoding.compatible?(Encoding::EUC_JP, Encoding::UTF_8)<br>
=> nil<br>
ruby-1.9.3-p0 :002 > a = "abc".encode "euc-jp"<br>
=> "abc"<br>
ruby-1.9.3-p0 :003 > a.encoding<br>
=> #<a href="Encoding:EUC-JP" class="external">Encoding:EUC-JP</a><br>
ruby-1.9.3-p0 :004 > a.valid_encoding?<br>
=> true<br>
ruby-1.9.3-p0 :005 > b = "def".encode "utf-8"<br>
=> "def"<br>
ruby-1.9.3-p0 :006 > b.encoding<br>
=> #<a href="Encoding:UTF-8" class="external">Encoding:UTF-8</a><br>
ruby-1.9.3-p0 :007 > b.valid_encoding?<br>
=> true<br>
ruby-1.9.3-p0 :008 > Encoding.compatible?(a, b)<br>
=> #<a href="Encoding:EUC-JP" class="external">Encoding:EUC-JP</a><br>
ruby-1.9.3-p0 :009 > a << b<br>
=> "abcdef"<br>
ruby-1.9.3-p0 :010 > a.encoding<br>
=> #<a href="Encoding:EUC-JP" class="external">Encoding:EUC-JP</a><br>
ruby-1.9.3-p0 :011 > a.valid_encoding?<br>
=> true</p>
<p>If this is not a bug, could someone please explain the rationale behind the behavior.</p>
<p>Thanks,<br>
Brian</p> Ruby master - Bug #5862 (Rejected): Strings not encoded in -E encodinghttps://redmine.ruby-lang.org/issues/58622012-01-08T09:37:55Zbrixen (Brian Shirai)brixen@gmail.com
<p>If I pass the -E option, the Encoding.default_external is set to that encoding, but the string in the -e code is not set to that encoding, nor is the value of <strong>ENCODING</strong> set to it.</p>
<p>$ ruby -v -E ascii-8bit -e 'p "abc".encoding, Encoding.default_external, Encoding.default_internal, <strong>ENCODING</strong>'<br>
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0]<br>
#<a href="Encoding:UTF-8" class="external">Encoding:UTF-8</a><br>
#<a href="Encoding:ASCII-8BIT" class="external">Encoding:ASCII-8BIT</a><br>
nil<br>
#<a href="Encoding:UTF-8" class="external">Encoding:UTF-8</a></p>
<p>However, if I pass -Ka, the encodings for all of 1. Encoding.default_external, 2. the -e string literal, and 3. <strong>ENCODING</strong> in -e code are set to eg ASCII-8BIT.</p>
<p>$ ruby -v -Ka -e 'p "abc".encoding, Encoding.default_external, Encoding.default_internal, <strong>ENCODING</strong>'<br>
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0]<br>
#<a href="Encoding:ASCII-8BIT" class="external">Encoding:ASCII-8BIT</a><br>
#<a href="Encoding:ASCII-8BIT" class="external">Encoding:ASCII-8BIT</a><br>
nil<br>
#<a href="Encoding:ASCII-8BIT" class="external">Encoding:ASCII-8BIT</a></p>
<p>If -E {enc} sets Encoding.default_external to {enc} and data read from IO streams is set to encoding Encoding.default_external, and STDIO is an IO stream, shouldn't passing -E {enc} cause the -e string literal to have encoding {enc}? If not, could someone please explain the exact semantics of these two different command line options.</p>
<p>Thanks,<br>
Brian</p> Ruby master - Bug #5836 (Closed): #slice results inconsistent after #force_encoding to a valid en...https://redmine.ruby-lang.org/issues/58362012-01-04T05:53:02Zbrixen (Brian Shirai)brixen@gmail.com
<p>I was not able to reduce this further. After calling #force_encoding, #slice returns inconsistent results:</p>
<p>ruby-1.9.3-p0 :001 > RUBY_DESCRIPTION<br>
=> "ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0]"<br>
ruby-1.9.3-p0 :002 > s = "abc"<br>
=> "abc"<br>
ruby-1.9.3-p0 :003 > s.size<br>
=> 3<br>
ruby-1.9.3-p0 :004 > s.encoding<br>
=> #<a href="Encoding:UTF-8" class="external">Encoding:UTF-8</a><br>
ruby-1.9.3-p0 :005 > s.valid_encoding?<br>
=> true<br>
ruby-1.9.3-p0 :006 > s.slice 3<br>
=> nil<br>
ruby-1.9.3-p0 :007 > s.slice 3, 1<br>
=> ""<br>
ruby-1.9.3-p0 :008 > s<br>
=> "abc"<br>
ruby-1.9.3-p0 :009 > s.force_encoding 'ascii-8bit'<br>
=> "abc"<br>
ruby-1.9.3-p0 :010 > s.slice 3<br>
=> nil<br>
ruby-1.9.3-p0 :011 > s.slice 3, 1<br>
=> ""<br>
ruby-1.9.3-p0 :012 > s<br>
=> "abc"<br>
ruby-1.9.3-p0 :013 > s.valid_encoding?<br>
=> true<br>
ruby-1.9.3-p0 :014 > s.force_encoding 'euc-jp'<br>
=> "abc"<br>
ruby-1.9.3-p0 :015 > s.slice 3<br>
=> nil<br>
ruby-1.9.3-p0 :016 > s.slice 3, 1<br>
=> nil<br>
ruby-1.9.3-p0 :017 > s.valid_encoding?<br>
=> true</p>
<p>Thanks,<br>
Brian</p> Ruby master - Bug #5830 (Rejected): "".byteslice(0) != "".byteslice(0, 0)https://redmine.ruby-lang.org/issues/58302011-12-31T17:32:17Zbrixen (Brian Shirai)brixen@gmail.com
<p>Is this a bug?</p>
<p>See <a href="https://github.com/ruby/ruby/blob/069f7ec90a6ef/string.c#L4091" class="external">https://github.com/ruby/ruby/blob/069f7ec90a6ef/string.c#L4091</a> vs <a href="https://github.com/ruby/ruby/blob/069f7ec90a6ef/string.c#L4035-4036" class="external">https://github.com/ruby/ruby/blob/069f7ec90a6ef/string.c#L4035-4036</a></p>
<p>Thanks,<br>
Brian</p> Ruby master - Bug #5647 (Closed): Possible use of uninitialized value in Init_bigdecimalhttps://redmine.ruby-lang.org/issues/56472011-11-18T17:52:22Zbrixen (Brian Shirai)brixen@gmail.com
<p>I see the following call chain in bigdecimal.c</p>
<p>Init_bigdecimal -> VpInit -> VpAlloc -> VpGetPrecLimit -> rb_thread_local_aref with id_BigDecimal_precision_limit</p>
<p>The call to VpInit occurs before the call to set the value of id_BigDecimal_precision_limit in Init_bigdecimal.</p>
<p>So it appears that a thread local is set with the key of an uninitialized C value, if I'm following correctly.</p>
<p>Thanks,<br>
Brian</p> Ruby master - Bug #5568 (Closed): IO#set_encoding ignores internal when the same as external only...https://redmine.ruby-lang.org/issues/55682011-11-04T12:49:42Zbrixen (Brian Shirai)brixen@gmail.com
<p>When passing two encoding objects that are the same to IO#set_encoding, both external and internal encodings for the IO instance are set.</p>
<p>However, when passing "ext:int", the internal encoding is not set if the same as external, but a warning is issued. Further, when passing "ext", "int", the internal encoding is not set and no warning is issued.</p>
<p>sasha:rubinius brian$ ruby2.0 -v -e 'p STDOUT.set_encoding("utf-8:utf-8").internal_encoding'<br>
ruby 2.0.0dev (2011-10-26 trunk 33526) [x86_64-darwin10.8.0]<br>
-e:1: warning: Ignoring internal encoding utf-8: it is identical to external encoding utf-8<br>
nil</p>
<p>sasha:rubinius brian$ ruby2.0 -v -e 'p STDOUT.set_encoding(Encoding::UTF_8, Encoding::UTF_8).internal_encoding'<br>
ruby 2.0.0dev (2011-10-26 trunk 33526) [x86_64-darwin10.8.0]<br>
#<a href="Encoding:UTF-8" class="external">Encoding:UTF-8</a></p>
<p>sasha:rubinius brian$ ruby2.0 -v -e 'p STDOUT.set_encoding("utf-8", "utf-8").internal_encoding'<br>
ruby 2.0.0dev (2011-10-26 trunk 33526) [x86_64-darwin10.8.0]<br>
nil</p>
<p>Is there a reason for these differences?</p>
<p>Thanks,<br>
Brian</p> Ruby master - Bug #5567 (Closed): IO#set_encoding ignores one invalid encoding unless a second ar...https://redmine.ruby-lang.org/issues/55672011-11-04T11:39:06Zbrixen (Brian Shirai)brixen@gmail.com
<p>IO.set_encoding will ignore one invalid encoding unless a second argument is passed. This is odd behavior. See below:</p>
<p>sasha:rubinius brian$ ruby2.0 -v -e 'STDOUT.set_encoding("wtfzomgbbq")'<br>
ruby 2.0.0dev (2011-10-26 trunk 33526) [x86_64-darwin10.8.0]<br>
-e:1: warning: Unsupported encoding wtfzomgbbq ignored</p>
<p>BUT</p>
<p>sasha:rubinius brian$ ruby2.0 -v -e 'STDOUT.set_encoding("wtfzomgbbq", "wtf")'<br>
ruby 2.0.0dev (2011-10-26 trunk 33526) [x86_64-darwin10.8.0]<br>
-e:1:in <code>set_encoding': unknown encoding name - wtfzomgbbq (ArgumentError) from -e:1:in </code>'</p>
<p>Is this intentional?</p>
<p>If this is fixed, please backport to 1.9.2 or 3.</p>
<p>Thanks,<br>
Brian</p> Ruby master - Bug #5556 (Closed): SIGHUP no longer ignored when sent to process group from a subp...https://redmine.ruby-lang.org/issues/55562011-11-03T08:07:21Zbrixen (Brian Shirai)brixen@gmail.com
<p>Hi,</p>
<p>Prior to 2.0.0dev, this script:</p>
<p>sasha:rubinius brian$ cat process.rb<br>
puts "before system"<br>
system("ruby -e 'Process.kill(:HUP, 0)'")<br>
puts "after system"</p>
<p>would print the following:</p>
<p>sasha:rubinius brian$ ruby1.9.2 -v process.rb<br>
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]<br>
before system<br>
after system</p>
<p>Basically, SIGHUP was ignored when sent from a subprocess. Presently, this is the result:</p>
<p>sasha:rubinius brian$ ruby -v process.rb<br>
ruby 2.0.0dev (2011-11-01 trunk 33596) [x86_64-darwin10.8.0]<br>
before system<br>
Hangup</p>
<p>The following issue may be related, but the explanation is in Japanese, so I cannot follow it: <a href="http://redmine.ruby-lang.org/issues/4765" class="external">http://redmine.ruby-lang.org/issues/4765</a></p>
<p>Is this change intentional? I discovered it running RubySpec, where there are specs for the behavior of sending SIGHUP to the process group.</p>
<p>Thanks,<br>
Brian</p> Ruby master - Bug #5490 (Closed): Bignum#div(0.0) raises FloatDomainError instead of ZeroDivision...https://redmine.ruby-lang.org/issues/54902011-10-27T10:31:49Zbrixen (Brian Shirai)brixen@gmail.com
<p>Bignum#div(0.0) raises FloatDomainError. Everything else raises ZeroDivisionError.</p>
<p>This should be fixed in both 1.9.3 and 2.0.0.</p>
<p>sasha:rubinius brian$ ruby -v<br>
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]<br>
sasha:rubinius brian$ irb<br>
ruby-1.9.2-p290 :001 > 1.div 0.0<br>
ZeroDivisionError: divided by 0<br>
from (irb):1:in <code>div' from (irb):1 from /Users/brian/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in </code>'<br>
ruby-1.9.2-p290 :002 > 1.1.div 0.0<br>
ZeroDivisionError: divided by 0<br>
from (irb):2:in <code>div' from (irb):2 from /Users/brian/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in </code>'<br>
ruby-1.9.2-p290 :003 > Rational(1).div 0.0<br>
ZeroDivisionError: divided by 0<br>
from (irb):3:in <code>div' from (irb):3 from /Users/brian/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in </code>'<br>
ruby-1.9.2-p290 :004 > 0xffff_ffff_ffff_ffff.div 0.0<br>
FloatDomainError: Infinity<br>
from (irb):4:in <code>div' from (irb):4 from /Users/brian/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in </code>'</p>
<p>Thanks,<br>
Brian</p> Backport187 - Backport #5452 (Closed): String#squeeze[!] with negated out-of-order sequence behav...https://redmine.ruby-lang.org/issues/54522011-10-16T08:51:30Zbrixen (Brian Shirai)brixen@gmail.com
<p>See the examples below:</p>
<p>String#squeeze!</p>
<p>$ ruby -e 'p "-subbookkeeper-".squeeze!("b-e")'<br>
"-subookkeper-"</p>
<p>$ ruby -e 'p "-subbookkeeper-".squeeze!("^b-e")'<br>
"-subbokeeper-"</p>
<p>$ ruby -e 'p "-subbookkeeper-".squeeze!("e-b")'<br>
nil</p>
<p>$ ruby -e 'p "-subbookkeeper-".squeeze!("^e-b")'<br>
"-subokeper-"</p>
<p>^^^ This looks like a bug</p>
<p>$ ruby -e 'p "-subbookkeeper-".squeeze!'<br>
"-subokeper-"</p>
<p>String#squeeze</p>
<p>$ ruby -e 'p "-subbookkeeper-".squeeze("e-b")'<br>
"-subbookkeeper-"</p>
<p>$ ruby -e 'p "-subbookkeeper-".squeeze("^e-b")'<br>
"-subokeper-"</p>
<p>^^^ And so does this</p>
<p>$ ruby -e 'p "-subbookkeeper-".squeeze'<br>
"-subokeper-"</p>
<p>Thanks,<br>
Brian</p> Backport187 - Backport #5319 (Closed): Problem backporting [ruby-dev:38672] to 1.8.7p334https://redmine.ruby-lang.org/issues/53192011-09-14T06:02:07Zbrixen (Brian Shirai)brixen@gmail.com
<p>It appears that the change in <a href="/issues/1645">[ruby-dev:38672]</a> was not backported correctly to 1.8.7p334</p>
<a name="comparisonrb"></a>
<h1 >comparison.rb<a href="#comparisonrb" class="wiki-anchor">¶</a></h1>
<p>inf = 1.0/0.0<br>
b = Float::MAX.to_i * 2</p>
<p>p(inf <=> b) # => should be 1<br>
p(b <=> inf) # => should be -1</p>
<p>p(inf <=> (-b)) # => should be 1<br>
p((-b) <=> inf) # => should be -1</p>
<p>p((-inf) <=> b) # should be -1<br>
p(b <=> (-inf)) # should be 1</p>
<p>p((-inf) <=> (-b)) # should be -1<br>
p((-b) <=> (-inf)) # should be 1</p>
<p>$ ruby1.9.2 -v comparison.rb<br>
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]<br>
1<br>
-1<br>
1<br>
-1<br>
-1<br>
1<br>
-1<br>
1</p>
<p>$ ruby1.8.7 -v comparison.rb<br>
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10.8.0]<br>
comparison.rb:4: warning: Bignum out of Float range<br>
0<br>
comparison.rb:5: warning: Bignum out of Float range<br>
0<br>
comparison.rb:7: warning: Bignum out of Float range<br>
0<br>
comparison.rb:8: warning: Bignum out of Float range<br>
0<br>
comparison.rb:10: warning: Bignum out of Float range<br>
-1<br>
comparison.rb:11: warning: Bignum out of Float range<br>
1<br>
comparison.rb:13: warning: Bignum out of Float range<br>
-1<br>
comparison.rb:14: warning: Bignum out of Float range<br>
1</p>
<p>Thanks,<br>
Brian</p> Ruby master - Bug #5309 (Rejected): 0.6.to_r != "0.6".to_rhttps://redmine.ruby-lang.org/issues/53092011-09-13T03:06:44Zbrixen (Brian Shirai)brixen@gmail.com
<p>0.6.to_r != "0.6".to_r</p>
<p>Is this a bug?</p>
<p>$ ruby -v<br>
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]</p>
<p>$ irb<br>
ruby-1.9.2-p290 :001 > 0.6.to_r<br>
=> (5404319552844595/9007199254740992)<br>
ruby-1.9.2-p290 :002 > "0.6".to_r<br>
=> (3/5)<br>
ruby-1.9.2-p290 :003 > a = "%.55f" % 0.6<br>
=> "0.5999999999999999777955395074968691915273666381835937500"<br>
ruby-1.9.2-p290 :004 > b = "%.55f" % "0.6".to_f<br>
=> "0.5999999999999999777955395074968691915273666381835937500"<br>
ruby-1.9.2-p290 :005 > a == b<br>
=> true</p>
<p>Thanks,<br>
Brian</p> Ruby master - Bug #5304 (Rejected): Array#pack handles objects for eg format 'E' differently than...https://redmine.ruby-lang.org/issues/53042011-09-10T05:32:34Zbrixen (Brian Shirai)brixen@gmail.com
<p>In 1.9, Array#pack when passed an object that defines #to_f and one of the Float formats raises a TypeError. This is a change from 1.8. The code in 1.9 calls rb_to_float()</p>
<a name="19"></a>
<h1 >1.9<a href="#19" class="wiki-anchor">¶</a></h1>
<p>VALUE<br>
rb_to_float(VALUE val)<br>
{<br>
if (TYPE(val) == T_FLOAT) return val;<br>
if (!rb_obj_is_kind_of(val, rb_cNumeric)) {<br>
rb_raise(rb_eTypeError, "can't convert %s into Float",<br>
NIL_P(val) ? "nil" :<br>
val == Qtrue ? "true" :<br>
val == Qfalse ? "false" :<br>
rb_obj_classname(val));<br>
}<br>
return rb_convert_type(val, T_FLOAT, "Float", "to_f");<br>
}</p>
<p>The rb_to_float() imposes the (arbitrary) restriction that the object be kind of Numeric. The 1.8 pack code used rb_Float(), which merely requires the object respond to #to_f and return a Float.</p>
<p>The treatment of objects in 1.9 for the float formats is thus different than for eg the integer formats, where the object simply must respond to #to_int. The requirement that the object be a kind of Numeric breaks the uniform ducktyping and imposes an arbitrary and unnecessary type/class requirement.</p>
<p>Was this change intended, and if so, why? Apologies if this was discussed on ruby-core prior to the change; I could not find any discussion through searching.</p>
<p>The following code illustrates the issue:</p>
<p>o = Object.new</p>
<p>def o.to_int<br>
puts "to_int called"<br>
1<br>
end</p>
<p>def o.to_f<br>
puts "to_f called"<br>
1.1<br>
end</p>
<p>p [o].pack("I") # => "\001..." (depends on endianness)<br>
p [o].pack("E") # => 1.8 - ""; 1.9 - TypeError</p>
<p>$ ruby1.8.7 -v pack_test.rb<br>
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10.8.0]<br>
to_int called<br>
"\001\000\000\000"<br>
to_f called<br>
"\232\231\231\231\231\231\361?"</p>
<p>$ ruby1.9.2 -v pack_test.rb<br>
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]<br>
to_int called<br>
"\x01\x00\x00\x00"<br>
pack_test.rb:14:in <code>pack': can't convert Object into Float (TypeError) from pack_test.rb:14:in </code>'</p> Ruby master - Bug #5237 (Closed): IO.copy_stream calls #read on an object infinitely many timeshttps://redmine.ruby-lang.org/issues/52372011-08-27T11:58:11Zbrixen (Brian Shirai)brixen@gmail.com
<p>The code for IO.copy_stream appears to support passing any object that implements #readpartial or #read. For example, passing an instance of StringIO works just fine:</p>
<p>sasha:rubinius2.0 brian$ irb<br>
ruby-1.9.2-p290 :001 > puts RUBY_DESCRIPTION<br>
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]<br>
=> nil<br>
ruby-1.9.2-p290 :002 > require 'stringio'<br>
=> true<br>
ruby-1.9.2-p290 :003 > s = StringIO.new "this is a test"<br>
=> #<a href="StringIO:0x00000100851190" class="external">StringIO:0x00000100851190</a><br>
ruby-1.9.2-p290 :004 > IO.copy_stream s, "copy_stream_stringio"<br>
=> 14<br>
ruby-1.9.2-p290 :005 > IO.read "copy_stream_stringio"<br>
=> "this is a test"<br>
ruby-1.9.2-p290 :006 ></p>
<p>However, passing an object that implements eg #read according to the specification of IO#read, causes IO.copy_stream to endlessly call #read on the object:</p>
<p>class A<br>
def initialize<br>
@count = 0<br>
end</p>
<p>def read(bytes, buffer)<br>
print "read: #{@count += 1}\r"<br>
buffer.replace "this is a test"<br>
return nil<br>
end<br>
end</p>
<p>a = A.new<br>
IO.copy_stream a, "copy_stream_test"</p>
<p>ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]<br>
copy_stream_bug.rb:7:in <code>write': Interrupt from copy_stream_bug.rb:7:in </code>print'<br>
from copy_stream_bug.rb:7:in <code>read' from copy_stream_bug.rb:14:in </code>copy_stream'<br>
from copy_stream_bug.rb:14:in `'</p>
<p>Thanks,<br>
Brian</p> Ruby master - Bug #4571 (Closed): YAML.load given an ISO8601 timestamp creates an incorrect value...https://redmine.ruby-lang.org/issues/45712011-04-12T08:18:05Zbrixen (Brian Shirai)brixen@gmail.com
<p>=begin<br>
$ ruby1.8.7 -v -ryaml -e 'p YAML.load("2011-03-22t23:32:11.000000342222+01:00").usec'<br>
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin9.8.0]<br>
342222</p>
<p>$ ruby1.9.2 -v -ryaml -e 'p YAML.load("2011-03-22t23:32:11.000000342222+01:00").usec'<br>
ruby 1.9.2p180 (2011-02-18 revision 30909) [i386-darwin9.8.0]<br>
342222</p>
<p>$ ruby1.9 -v -ryaml -e 'p YAML.load("2011-03-22t23:32:11.000000342222+01:00").usec'<br>
ruby 1.9.3dev (2011-04-12 trunk 31263) [i386-darwin9.8.0]<br>
342222</p>
<p>I believe these should be 0.</p>
<p>Thanks,<br>
Brian<br>
=end</p> Backport187 - Backport #4087 (Closed): String#scan(arg) taints results if arg is a Regexp but not...https://redmine.ruby-lang.org/issues/40872010-11-25T05:38:24Zbrixen (Brian Shirai)brixen@gmail.com
<p>=begin<br>
Is this intended? If so, would you please explain the rationale.</p>
<p>$ ruby -v -e '"hello hello hello".scan(/hello/.taint).each { |m| p m.tainted? }'<br>
ruby 1.8.6 (2009-06-08 patchlevel 369) [universal-darwin9.0]<br>
true<br>
true<br>
true</p>
<p>$ ruby1.8.7 -v -e '"hello hello hello".scan(/hello/.taint).each { |m| p m.tainted? }'<br>
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin9.8.0]<br>
true<br>
true<br>
true</p>
<p>$ ruby1.9.2 -v -e '"hello hello hello".scan(/hello/.taint).each { |m| p m.tainted? }'<br>
ruby 1.9.2p0 (2010-08-18 revision 29036) [i386-darwin9.8.0]<br>
true<br>
true<br>
true</p>
<p>$ ruby -v -e '"hello hello hello".scan("hello".taint).each { |m| p m.tainted? }'<br>
ruby 1.8.6 (2009-06-08 patchlevel 369) [universal-darwin9.0]<br>
false<br>
false<br>
false</p>
<p>$ ruby1.8.7 -v -e '"hello hello hello".scan("hello".taint).each { |m| p m.tainted? }'<br>
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin9.8.0]<br>
false<br>
false<br>
false</p>
<p>$ ruby1.9.2 -v -e '"hello hello hello".scan("hello".taint).each { |m| p m.tainted? }'<br>
ruby 1.9.2p0 (2010-08-18 revision 29036) [i386-darwin9.8.0]<br>
false<br>
false<br>
false</p>
<p>Thanks,<br>
Brian<br>
=end</p> Backport187 - Backport #3362 (Closed): rb_big2dbl incorrectly returns Infinity for a negative Big...https://redmine.ruby-lang.org/issues/33622010-05-29T15:26:19Zbrixen (Brian Shirai)brixen@gmail.com
<p>=begin<br>
Revision 12261 changed rb_big2dbl in a way that caused a negative Bignum out of range of a double to be returned as Infinity rather than -Infinity. This was a regression that appears to be fixed in 1.9 but is still present in 1.8.7p249.</p>
<p>Could a fix for this be backported to 1.8.7 or are no further 1.8.7 versions being released? Also, the bug is still in <a href="http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8" class="external">http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8</a> so would presumably appear an a 1.8.8 release.</p>
<p>Thanks,<br>
Brian<br>
=end</p> Ruby master - Bug #3217 (Rejected): Regexp fails to match string with '<' when encoding is UTF-8https://redmine.ruby-lang.org/issues/32172010-04-29T03:49:26Zbrixen (Brian Shirai)brixen@gmail.com
<p>=begin<br>
Hi,</p>
<p>There is an issue matching a string like "a <em>b</em> c <em>d</em><" when the encoding of the file is set to UTF-8 and the regexp is attempting to match '<em>something</em>'. Afaik, *< is not special in the encoding.</p>
<p>This gist illustrates the issue:</p>
<p><a href="http://gist.github.com/382510" class="external">http://gist.github.com/382510</a></p>
<p>Thanks,<br>
Brian<br>
=end</p> Ruby master - Feature #3185 (Rejected): File.expand_path repeats forward slashes at the beginning...https://redmine.ruby-lang.org/issues/31852010-04-22T07:42:11Zbrixen (Brian Shirai)brixen@gmail.com
<p>=begin<br>
When File.expand_path is passed a string with multiple consecutive forward slashes, it preserves them in the output. This would appear to be a bug since everywhere else in the path, consecutive separators are collapsed to a single one.</p>
<p>$ ruby1.8.7 -v -e 'p File.expand_path("//////some/dir")'<br>
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-darwin9.8.0]<br>
"//////some/dir"</p>
<p>$ ruby1.8.7 -v -e 'p File.expand_path("//////some/dir", "/Foo")'<br>
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-darwin9.8.0]<br>
"//////some/dir"</p>
<p>The same behavior exists on 1.9.</p>
<p>$ ruby1.9 -v -e 'p File.expand_path("//////some/dir")'<br>
ruby 1.9.2dev (2010-03-30 trunk 27097) [i386-darwin9.8.0]<br>
"//////some/dir"<br>
$ ruby1.9 -v -e 'p File.expand_path("//////some/dir", "/Foo")'<br>
ruby 1.9.2dev (2010-03-30 trunk 27097) [i386-darwin9.8.0]<br>
"//////some/dir"</p>
<p>Thanks,<br>
Brian<br>
=end</p> Ruby 1.8 - Bug #3171 (Closed): require '~/file.rb does not expand path before storing in $"https://redmine.ruby-lang.org/issues/31712010-04-19T11:37:37Zbrixen (Brian Shirai)brixen@gmail.com
<p>=begin<br>
Calling 'require "~/file.rb"' does not expand the path before storing it in $". However, 'require "~/file"' does expand the path. In both cases, the path is expanded for <strong>FILE</strong>.</p>
<p>$ cat ~/file.rb<br>
puts <strong>FILE</strong></p>
<p>$ ruby1.8.7 -v -e 'require "~/file"; p $"'<br>
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-darwin9.8.0]<br>
/Users/brian/file.rb<br>
["enumerator.so", "/Users/brian/file.rb"]</p>
<p>$ ruby1.8.7 -v -e 'require "~/file.rb"; p $"'<br>
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-darwin9.8.0]<br>
/Users/brian/file.rb<br>
["enumerator.so", "~/file.rb"]</p>
<p>This bug has been fixed in 1.9.2, but I could not find a specific ticket for it. The fix should be backported to 1.8.</p>
<p>$ ruby1.9 -v -e 'require "~/file"; p $".grep(/file/)'<br>
ruby 1.9.2dev (2010-03-30 trunk 27097) [i386-darwin9.8.0]<br>
/Users/brian/file.rb<br>
["/Users/brian/file.rb"]</p>
<p>$ ruby1.9 -v -e 'require "~/file.rb"; p $".grep(/file/)'<br>
ruby 1.9.2dev (2010-03-30 trunk 27097) [i386-darwin9.8.0]<br>
/Users/brian/file.rb<br>
["/Users/brian/file.rb"]</p>
<p>Thanks,<br>
Brian<br>
=end</p> Ruby master - Bug #2756 (Rejected): Issues with Math and Complex behavior on 1.9https://redmine.ruby-lang.org/issues/27562010-02-18T04:10:06Zbrixen (Brian Shirai)brixen@gmail.com
<p>This ticket aggregates several issues with Math methods on 1.9. There are related tickets that either have not yet or do not, in my opinion, resolve these issues in a satisfactory manner. (see <a href="http://redmine.ruby-lang.org/issues/show/1708" class="external">http://redmine.ruby-lang.org/issues/show/1708</a>, and related to the behavior of Math <a href="http://redmine.ruby-lang.org/issues/show/2189" class="external">http://redmine.ruby-lang.org/issues/show/2189</a> and to 1.8 behavior <a href="http://redmine.ruby-lang.org/issues/show/2754" class="external">http://redmine.ruby-lang.org/issues/show/2754</a>)</p>
<a name="1-There-are-behaviors-that-are-inconsistent-with-18"></a>
<h2 >1. There are behaviors that are inconsistent with 1.8<a href="#1-There-are-behaviors-that-are-inconsistent-with-18" class="wiki-anchor">¶</a></h2>
<pre><code># On 1.8, the argument is coerced
$ ruby1.8.7 -v -e 'o = Object.new; def o.to_f; 0.5; end; p Math.atanh(o)'ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin9.8.0]
0.549306144334055
# On 1.9, the argement is not coerced
$ ruby1.9 -v -e 'o = Object.new; def o.to_f; 0.5; end; p Math.atanh(o)'
ruby 1.9.2dev (2010-02-18 trunk 26704) [i386-darwin9.8.0]
-e:1:in `atanh': can't convert Object into Float (TypeError)
from -e:1:in `<main>'
</code></pre>
<p>Q. Should 1.9 coerce arguments to Math methods?</p>
<pre><code># On 1.8, an ArgmentError is raised
$ ruby1.8.7 -v -e 'p Math.atanh("str")'
ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin9.8.0]
-e:1:in `atanh': invalid value for Float(): "str" (ArgumentError)
from -e:1
# On 1.9, a TypeError is raised
$ ruby1.9 -v -e 'p Math.atanh("str")'
ruby 1.9.2dev (2010-02-18 trunk 26704) [i386-darwin9.8.0]
-e:1:in `atanh': can't convert String into Float (TypeError)
from -e:1:in `<main>'
</code></pre>
<p>Q. In this case, TypeError would appear more correct, so can the 1.8.7 behavior be changed? Also note that changing the 1.8.7 behavior would make it consistent with the behavior of atanh when requiring Complex (see <a href="http://redmine.ruby-lang.org/issues/show/2754" class="external">http://redmine.ruby-lang.org/issues/show/2754</a>)</p>
<a name="2-There-are-behaviors-that-are-inconsistent-when-requiring-libcomplexrb"></a>
<h2 >2. There are behaviors that are inconsistent when requiring lib/complex.rb<a href="#2-There-are-behaviors-that-are-inconsistent-when-requiring-libcomplexrb" class="wiki-anchor">¶</a></h2>
<pre><code># The original method raise a TypeError
$ ruby1.9 -v -e 'p Math.atanh(nil)'
ruby 1.9.2dev (2010-02-18 trunk 26704) [i386-darwin9.8.0]
-e:1:in `atanh': can't convert nil into Float (TypeError)
from -e:1:in `<main>'
# The new method attempts an undefined operation and consequently raises a NoMethodError
$ ruby1.9 -v -rcomplex -e 'p Math.atanh(nil)'
ruby 1.9.2dev (2010-02-18 trunk 26704) [i386-darwin9.8.0]
lib/complex.rb is deprecated
/Users/brian/devel/ruby19/install/lib/ruby/1.9.1/cmath.rb:196:in `atanh': undefined method `real?' for nil:NilClass (NoMethodError)
from -e:1:in `<main>'
</code></pre>
<p>The same behavior is observed when passing a String.</p>
<p>Q. Should the behavior of atanh after requiring lib/complex.rb be the same for non-Complex inputs as before?</p>
<p>Also, requiring lib/complex.rb on 1.9 causes a warning: "lib/complex.rb is deprecated". But this is not entirely true. As best as I can understand from <a href="http://redmine.ruby-lang.org/issues/show/1708" class="external">http://redmine.ruby-lang.org/issues/show/1708</a>, it was never decided whether complex.rb should require cmath.rb. It appears that there are some behaviors acquired via lib/complex.rb that are not deprecated. In that case, this warning is confusing and misleading.</p>
<p>Q. Is lib/complex.rb deprecated or not? If it is, why is it deprecated and not removed? 1.9 already removes many libraries. Why is this one special and allowed to cause such confusion?</p>
<p>Q. Is there a definitive document that explains the policy and behavior of Math and Complex in 1.9?</p>
<hr>
<p>To summarize the questions in this ticket?</p>
<ul>
<li>Q. Should 1.9 coerce arguments to Math methods?</li>
<li>Q. Can we change the 1.8.7 behavior when raising exceptions to be both internally consistent and consistent with the behavior of 1.9 (Note that numerous changes to the exception raised have already been made in 1.8.5 -> 1.8.6 -> 1.8.7, so this request is not without precedent.) (see <a href="http://redmine.ruby-lang.org/issues/show/2754" class="external">http://redmine.ruby-lang.org/issues/show/2754</a>)</li>
<li>Q. Should the behavior of atanh after requiring lib/complex.rb be the same for non-Complex inputs as before?</li>
<li>Q. Is lib/complex.rb deprecated or not? If it is, <em>why</em> is it deprecated and not removed?</li>
<li>Q. Is there a definitive document that explains the policy and behavior of Math and Complex in 1.9?</li>
</ul>
<p>Thanks,<br>
Brian</p> Backport187 - Backport #2754 (Closed): Inconsistent behavior of Math methods on 1.8 when requirin...https://redmine.ruby-lang.org/issues/27542010-02-18T03:33:30Zbrixen (Brian Shirai)brixen@gmail.com
<p>=begin<br>
On 1.8, requiring lib/complex.rb changes the behavior of Math methods to be Complex-aware. However, the new methods do not behave consistently with the methods they are replacing on various aspects not involving Complex numbers.</p>
<p>Here is an example with Math.atanh:</p>
<a name="The-original-method-coerces-an-argument"></a>
<h1 >The original method coerces an argument<a href="#The-original-method-coerces-an-argument" class="wiki-anchor">¶</a></h1>
<p>$ ruby1.8.7 -v -e 'o = Object.new; def o.to_f; 0.5; end; p Math.atanh(o)'<br>
ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin9.8.0]<br>
0.549306144334055</p>
<a name="The-new-method-does-not"></a>
<h1 >The new method does not<a href="#The-new-method-does-not" class="wiki-anchor">¶</a></h1>
<p>$ ruby1.8.7 -v -rcomplex -e 'o = Object.new; def o.to_f; 0.5; end; p Math.atanh(o)'<br>
ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin9.8.0]<br>
/Users/brian/devel/ruby187/install/lib/ruby/1.8/complex.rb:614:in <code>+': Object can't be coerced into Float (TypeError) from /Users/brian/devel/ruby187/install/lib/ruby/1.8/complex.rb:614:in </code>atanh'<br>
from -e:1</p>
<a name="The-original-method-raises-an-ArgumentError"></a>
<h1 >The original method raises an ArgumentError<a href="#The-original-method-raises-an-ArgumentError" class="wiki-anchor">¶</a></h1>
<p>$ ruby1.8.7 -v -e 'p Math.atanh("str")'ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin9.8.0]<br>
-e:1:in `atanh': invalid value for Float(): "str" (ArgumentError)<br>
from -e:1</p>
<a name="The-new-method-raises-a-TypeError"></a>
<h1 >The new method raises a TypeError<a href="#The-new-method-raises-a-TypeError" class="wiki-anchor">¶</a></h1>
<p>$ ruby1.8.7 -v -rcomplex -e 'p Math.atanh("str")'<br>
ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin9.8.0]<br>
/Users/brian/devel/ruby187/install/lib/ruby/1.8/complex.rb:614:in <code>+': String can't be coerced into Float (TypeError) from /Users/brian/devel/ruby187/install/lib/ruby/1.8/complex.rb:614:in </code>atanh'<br>
from -e:1</p>
<p>These methods should behave consistently on all inputs that are not Complex.</p>
<p>There are numerous tickets related to Complex and Math interaction. I was unable to find one that states a satisfactory explanation to this issue. If there is one, please direct me to it and I apologize for the noise.</p>
<p>Thanks,<br>
Brian<br>
=end</p> Ruby master - Bug #2730 (Closed): Some methods still failing to raise RuntimeError when a frozen ...https://redmine.ruby-lang.org/issues/27302010-02-10T09:04:58Zbrixen (Brian Shirai)brixen@gmail.com
<p>=begin<br>
Per matz's request in <a href="https://blade.ruby-lang.org/ruby-core/23714">[ruby-core:23714]</a>, this ticket is for the methods that are still not raising a RuntimeError when called on a frozen object that would not be modified.</p>
<p>Array#concat<br>
Array#flatten!<br>
Array#insert<br>
Array#uniq!<br>
Array#unshift<br>
Hash#initialize_copy<br>
Hash#replace<br>
String#replace</p>
<p>These failures can be seen running RubySpec HEAD. They were previously masked by improper ruby_bug guards.</p>
<p>Thanks,<br>
Brian<br>
=end</p> Ruby master - Feature #2710 (Rejected): Kernel#load loads a relative pathhttps://redmine.ruby-lang.org/issues/27102010-02-04T02:59:36Zbrixen (Brian Shirai)brixen@gmail.com
<p>=begin<br>
It was my understanding that Kernel#require was changed to not load a relative path because of a security issue (<a href="http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/24155" class="external">http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/24155</a>). Does this security issue not apply to Kernel#load, too? Have I misunderstood the expected behavior?</p>
<p>$ cat a.rb<br>
puts 1</p>
<p>$ cat b.rb<br>
load 'a.rb'<br>
require 'a.rb'</p>
<p>$ ruby1.8.7 -v b.rb<br>
ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin9.8.0]<br>
1<br>
1</p>
<p>$ ruby1.9 -v b.rb<br>
ruby 1.9.2dev (2010-02-03 trunk 26546) [i386-darwin9.8.0]<br>
1<br>
b.rb:2:in <code>require': no such file to load -- a.rb (LoadError) from b.rb:2:in </code>'</p>
<p>$ RUBYLIB=. ruby1.9 -v b.rb<br>
ruby 1.9.2dev (2010-02-03 trunk 26546) [i386-darwin9.8.0]<br>
1<br>
1</p>
<p>Thanks,<br>
Brian<br>
=end</p> Ruby master - Bug #2578 (Closed): Requiring a relative path with an empty $LOAD_PATH raises LoadE...https://redmine.ruby-lang.org/issues/25782010-01-09T17:35:02Zbrixen (Brian Shirai)brixen@gmail.com
<p>=begin<br>
Hi,</p>
<p>While revising the rubyspecs for Kernel#require, I noticed the following difference between 1.8 and 1.9. If $LOAD_PATH is empty, requiring a path relative to the CWD raises a LoadError on 1.8 but succeeds on 1.9. Adding any entry to $LOAD_PATH, even a nonexistent directory, causes the relative require to succeed.</p>
<p>I've tried searching for a ticket related to this but was unable to find one. Is this a bug in 1.8? If not a bug, could you please explain the reason for the difference.</p>
<p>$ cat a.rb<br>
puts 1</p>
<p>$ cat b.rb<br>
p $LOAD_PATH.clear<br>
require './a.rb'</p>
<p>$ cat c.rb<br>
p $LOAD_PATH.clear<br>
p $LOAD_PATH << "irrelevant_dir"<br>
require './a.rb'</p>
<p>$ ruby1.8.7 -v b.rb<br>
ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin9.8.0]<br>
[]<br>
b.rb:2:in `require': no such file to load -- ./a.rb (LoadError)<br>
from b.rb:2</p>
<p>$ ruby1.9 -v b.rb<br>
ruby 1.9.2dev (2009-12-16 trunk 26107) [i386-darwin9.8.0]<br>
[]<br>
1</p>
<p>$ ruby1.8.7 -v c.rb<br>
ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin9.8.0]<br>
[]<br>
["irrelevant_dir"]<br>
1</p>
<p>$ ruby1.9 -v c.rb<br>
ruby 1.9.2dev (2009-12-16 trunk 26107) [i386-darwin9.8.0]<br>
[]<br>
["irrelevant_dir"]<br>
1</p>
<p>Thanks,<br>
Brian<br>
=end</p> Ruby 1.8 - Backport #2556 (Closed): Should r24500 be backported to 1.8?https://redmine.ruby-lang.org/issues/25562010-01-05T05:49:51Zbrixen (Brian Shirai)brixen@gmail.com
<p>=begin<br>
Should <a href="http://redmine.ruby-lang.org/repositories/diff/ruby-19?rev=24500" class="external">http://redmine.ruby-lang.org/repositories/diff/ruby-19?rev=24500</a> be backported to 1.8?</p>
<p>$ ruby -v -rdate -e 'p Date.strptime("2010/1", "%Y/%W").to_s'<br>
ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0]<br>
"2010-01-10"<br>
$ ruby1.8.7 -v -rdate -e 'p Date.strptime("2010/1", "%Y/%W").to_s'<br>
ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin9.8.0]<br>
"2010-01-10"<br>
$ ruby1.9 -v -rdate -e 'p Date.strptime("2010/1", "%Y/%W").to_s'<br>
ruby 1.9.2dev (2009-12-16 trunk 26107) [i386-darwin9.8.0]<br>
"2010-01-04"</p>
<p>Monday of the first week of 2010 is clearly not 1/10, so the change in r24500 would seem to be a bug fix. I searched for a ticket for the change made in r24500 but could not find one.</p>
<p>Thanks,<br>
Brian<br>
=end</p> Ruby master - Bug #1418 (Closed): File.join repeats recursive array contentshttps://redmine.ruby-lang.org/issues/14182009-04-29T12:12:06Zbrixen (Brian Shirai)brixen@gmail.com
<p>=begin<br>
This was fixed for Array#join, see <a href="https://blade.ruby-lang.org/ruby-dev/37019">[ruby-dev:37019]</a>.</p>
<p>$ ruby1.8 -v<br>
ruby 1.8.8dev (2009-04-28 revision 23305) [i386-darwin9.6.0]</p>
<p>$ ruby1.8 file.rb<br>
"a/b"<br>
"a/b/a/b/[...]"</p>
<p>$ cat file.rb<br>
a = ["a", "b"]<br>
p File.join(a)<br>
a << a<br>
p File.join(a)</p>
<p>Behavior on 1.8.6, 1.8.7, 1.8.8 and 1.9 is the same.<br>
=end</p> Ruby master - Bug #1336 (Closed): Change in string representation of Floatshttps://redmine.ruby-lang.org/issues/13362009-03-31T14:21:19Zbrixen (Brian Shirai)brixen@gmail.com
<p>=begin<br>
Did the displayed formats of Floats change in 1.9?</p>
<p>There was a thread <a href="https://blade.ruby-lang.org/ruby-core/22595">[ruby-core:22595]</a> on the ML about the format of Floats and marshaling, but there does not appear to be any indication that the normal display format would change. Also, I did not see any mention of a change of format in the Changelog.</p>
<p>gauss:mspec brian$ ~/devel/ruby19/install/bin/ruby19 -v -e 'p 5.51'<br>
ruby 1.9.2dev (2009-02-12 trunk 22247) [i386-darwin9.6.0]<br>
5.51</p>
<p>gauss:mspec brian$ ruby1.9 -v -e 'p 5.51'<br>
ruby 1.9.2dev (2009-03-30 trunk 23098) [i386-darwin9.6.0]<br>
5.5099999999999998</p>
<p>gauss:mspec brian$ ruby1.9 -v -e 'puts 5.51'<br>
ruby 1.9.2dev (2009-03-30 trunk 23098) [i386-darwin9.6.0]<br>
5.5099999999999998<br>
=end</p> Ruby master - Bug #1024 (Closed): Array#zip does not convert arguments to arrayshttps://redmine.ruby-lang.org/issues/10242009-01-20T05:50:45Zbrixen (Brian Shirai)brixen@gmail.com
<p>=begin<br>
The RDoc for Array#zip states that it "Converts any arguments to arrays...", however it does not appear to do so.</p>
<p>euler:rubyspec brian$ cat array_zip.rb<br>
ary = Object.new</p>
<p>def ary.to_a; [1, 2]; end<br>
def ary.to_ary; [3, 4]; end</p>
<p>p [5, 6].zip(ary)</p>
<p>euler:rubyspec brian$ multiruby -vw array_zip.rb</p>
<p>VERSION = mri_1_9<br>
CMD = ~/.multiruby/install/mri_1_9/bin/ruby -vw array_zip.rb</p>
<p>ruby 1.9.1p5000 (2009-01-20 trunk 21676) [i386-darwin9.6.0]<br>
array_zip.rb:6:in <code>zip': undefined method </code>each' for #<a href="Object:0x3d6be8" class="external">Object:0x3d6be8</a> (NoMethodError)<br>
from array_zip.rb:6:in `'</p>
<p>RESULT = 256</p>
<p>VERSION = mri_rel_1_8_6<br>
CMD = ~/.multiruby/install/mri_rel_1_8_6/bin/ruby -vw array_zip.rb</p>
<p>ruby 1.8.6 (2009-01-19 patchlevel 303) [i686-darwin9.6.0]<br>
[[5, 3], [6, 4]]</p>
<p>RESULT = 0</p>
<p>VERSION = mri_rel_1_8_7<br>
CMD = ~/.multiruby/install/mri_rel_1_8_7/bin/ruby -vw array_zip.rb</p>
<p>ruby 1.8.7 (2009-01-19 patchlevel 89) [i686-darwin9.6.0]<br>
[[5, 3], [6, 4]]</p>
<p>RESULT = 0</p>
<p>VERSION = 1.8.6-p114<br>
CMD = ~/.multiruby/install/1.8.6-p114/bin/ruby -vw array_zip.rb</p>
<p>ruby 1.8.6 (2008-03-03 patchlevel 114) [i686-darwin9.5.0]<br>
[[5, 3], [6, 4]]</p>
<p>RESULT = 0</p>
<p>TOTAL RESULT = 1 failures out of 4</p>
<p>Passed: mri_rel_1_8_6, mri_rel_1_8_7, 1.8.6-p114<br>
Failed: mri_1_9<br>
=end</p> Backport187 - Backport #962 (Closed): Patch for Makefile rubyspec rules after 1.8/1.9 spec mergehttps://redmine.ruby-lang.org/issues/9622009-01-01T12:29:27Zbrixen (Brian Shirai)brixen@gmail.com
<p>=begin<br>
The attached patch fixes the Makefile rules for fetching and running the rubyspecs after the recent 1.8/1.9 specs were merged. I tested this on OS X 10.5.6 and Ubuntu 8.04 32-bit.</p>
<p>I made the patch against the following repo, but the approach should work for 1.8.6, 1.8.7, and 1.9:</p>
<p>URL: <a href="http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8" class="external">http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8</a><br>
Repository Root: <a href="http://svn.ruby-lang.org/repos/ruby" class="external">http://svn.ruby-lang.org/repos/ruby</a><br>
Repository UUID: b2dd03c8-39d4-4d8f-98ff-823fe69b080e<br>
Revision: 21206</p>
<p>The patch also changes the directory for the rubyspecs themselves to ./rubyspec/spec since the additional directory in ./rubyspec/spec/rubyspec seems unnecessary. The mspec source is still in ./rubyspec/mspec.<br>
=end</p>