Ruby Issue Tracking System: Issueshttps://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112010-02-15T07:50:14ZRuby Issue Tracking System
Redmine Ruby master - Bug #2745 (Closed): iseq_set_sequence: adjust bug (next inside begin...rescue)https://bugs.ruby-lang.org/issues/27452010-02-15T07:50:14Zmurphy (Kornelius Kalnbach)murphy@rubychan.de
<p>=begin<br>
Input:<br>
while true<br>
begin<br>
raise<br>
next<br>
rescue<br>
end<br>
break<br>
end</p>
<p>Output:<br>
-: [BUG] iseq_set_sequence: adjust bug<br>
ruby 1.9.2dev (2010-02-14 trunk 26664) [i386-darwin10.2.0]</p>
<h2>-- control frame ----------<br>
c:0001 p:0000 s:0002 b:0002 l:000be4 d:000be4 TOP</h2>
<p>-- C level backtrace information -------------------------------------------<br>
0 libruby19.1.9.1.dylib 0x00184ae5 rb_vm_bugreport + 229<br>
1 libruby19.1.9.1.dylib 0x00040e3b report_bug + 379<br>
2 libruby19.1.9.1.dylib 0x00040eec rb_bug + 44<br>
3 libruby19.1.9.1.dylib 0x001578eb iseq_setup + 5179<br>
4 libruby19.1.9.1.dylib 0x001635d7 rb_iseq_compile_node + 1607<br>
5 libruby19.1.9.1.dylib 0x001698ff rb_iseq_new_with_bopt_and_opt + 159<br>
6 libruby19.1.9.1.dylib 0x00169b6b rb_iseq_new_main + 107<br>
7 libruby19.1.9.1.dylib 0x0010997e process_options + 2830<br>
8 libruby19.1.9.1.dylib 0x00109c4b ruby_process_options + 155<br>
9 libruby19.1.9.1.dylib 0x0004690f ruby_options + 127<br>
10 ruby19 0x00001f17 main + 87<br>
11 ruby19 0x00001e75 start + 53</p>
<p>[NOTE]<br>
You may have encountered a bug in the Ruby interpreter or extension libraries.<br>
Bug reports are welcome.<br>
For details: <a href="http://www.ruby-lang.org/bugreport.html" class="external">http://www.ruby-lang.org/bugreport.html</a></p>
<p>Abort trap<br>
=end</p> Ruby master - Bug #2731 (Rejected): FileUtils.copy prints error message in $DEBUG mode when desti...https://bugs.ruby-lang.org/issues/27312010-02-10T15:03:18Zmurphy (Kornelius Kalnbach)murphy@rubychan.de
<p>=begin<br>
Trying to copy a file with Ruby:</p>
<p>$ touch source<br>
$ ls destination<br>
ls: destination: No such file or directory<br>
$ ruby -rfileutils -d -e 'FileUtils.copy "source", "destination"'<br>
Exception `Errno::ENOENT' at /usr/local/lib/ruby/1.9.1/fileutils.rb:1429 - No such file or directory - destination<br>
$ ls destination<br>
destination</p>
<p>While the copy succeeds, it prints this confusing message. I don't expect libraries to issue exceptions when performing standard operations. This affects the FileUtils methods install, mv, cp_r, and cp; but the problem is in Entry_#fu_same? (around lib/fileutils.rb:1426):</p>
<p>def fu_same?(a, b) #:nodoc:<br>
if fu_have_st_ino?<br>
st1 = File.stat(a)<br>
st2 = File.stat(b)<br>
st1.dev == st2.dev and st1.ino == st2.ino<br>
else<br>
File.expand_path(a) == File.expand_path(b)<br>
end<br>
rescue Errno::ENOENT<br>
return false<br>
end</p>
<p>So, File.stat(b) is checked even if b doesn't exist. The resulting error message is even explicitely captured and hidden by the rescue. For the methods in question, it is a common case that the destination file doesn't exist.</p>
<p>Here's a version that doesn't rely on exceptions:</p>
<p>def fu_same?(a, b) #:nodoc:<br>
return false if !File.exist?(a) || !File.exist?(b)<br>
if fu_have_st_ino?<br>
st1 = File.stat(a)<br>
st2 = File.stat(b)<br>
st1.dev == st2.dev and st1.ino == st2.ino<br>
else<br>
File.expand_path(a) == File.expand_path(b)<br>
end<br>
end</p>
<p>The problem exists across Ruby versions from 1.8.6 to 1.9.2dev.<br>
=end</p> Ruby master - Feature #1089 (Rejected): Stable sorting for sort and sort_byhttps://bugs.ruby-lang.org/issues/10892009-02-02T16:32:43Zmurphy (Kornelius Kalnbach)murphy@rubychan.de
<p>=begin<br>
I'd like to have stable sorting in Ruby. Stable sorting means that if two items are ==, they will retain their order in the list after sorting. In other words, stable sort does never switch two equal items.</p>
<p>In Ruby 1.9.1, you'd have to use something like</p>
<p>enum.sort_by.with_index { |a, i| [a, i] }</p>
<p>to achieve a stable sort in Ruby.</p>
<p>It would also be nice to minimize the number of comparisons, since method calling is expensive in Ruby.</p>
<p>Python is using a highly optimized implementation of a variant of merge sort, which is stable and uses very few comparisons (called Timsort after Tim Peters); maybe Ruby can adopt it for sort and sort_by:</p>
<p><a href="http://svn.python.org/projects/python/trunk/Objects/listsort.txt" class="external">http://svn.python.org/projects/python/trunk/Objects/listsort.txt</a></p>
<p>Introducing stable sorting would not be a problem for old code because the order of equal items after sorting is currently not specified.<br>
=end</p> Ruby master - Bug #1009 (Closed): shadowing outer local variable in test/unithttps://bugs.ruby-lang.org/issues/10092009-01-14T00:31:28Zmurphy (Kornelius Kalnbach)murphy@rubychan.de
<p>=begin<br>
trunk 21466 gives me:</p>
<p>/usr/local/lib/ruby19/1.9.1/test/unit/assertions.rb:31: warning: shadowing outer local variable - line</p>
<p>It should<br>
=end</p> Backport186 - Backport #954 (Closed): OpenStruct#inspect recursion detection is buggyhttps://bugs.ruby-lang.org/issues/9542008-12-30T23:49:09Zmurphy (Kornelius Kalnbach)murphy@rubychan.de
<p>=begin<br>
Currently, OpenStruct#inspect shows a recursion indicator whenever a member of an OpenStruct is an OpenStruct itself:</p>
<p>foo = OpenStruct.new<br>
foo.bar = OpenStruct.new<br>
foo.inspect # => #<OpenStruct bar=#<OpenStruct ...>></p>
<p>I expect it to do the following:</p>
<p>foo = OpenStruct.new<br>
foo.bar = OpenStruct.new<br>
assert_equal('#<OpenStruct bar=#>', foo.inspect)<br>
foo.bar.foo = foo<br>
assert_equal('#<OpenStruct bar=#<OpenStruct foo=#<OpenStruct ...>>>', foo.inspect)</p>
<p>Path attached. It uses the code pattern found in Set#inspect, using object_ids instead of objects for the :<strong>inspect_key</strong> stack.</p>
<p>It should be fixed in Ruby 1.8.6 and 1.8.7, too.<br>
=end</p> Ruby master - Bug #952 (Closed): rb_obj_not_match documentation is buggyhttps://bugs.ruby-lang.org/issues/9522008-12-30T22:32:02Zmurphy (Kornelius Kalnbach)murphy@rubychan.de
<p>=begin<br>
The documentation for Object#!~ is currently incorrect and grammatically wrong, it says:</p>
<p>/*</p>
<ul>
<li>call-seq:</li>
<li>
<pre><code>obj !~ other => nil
</code></pre>
</li>
<li>
<li>Returns true if two objects does not match, using <i>=~</i> method.<br>
*/</li>
</ul>
<p>It should be replaced with something like this:</p>
<p>/*</p>
<ul>
<li>call-seq:</li>
<li>
<pre><code>obj !~ other => true or false
</code></pre>
</li>
<li>
<li>Returns true if two objects do not match (using the <i>=~</i>
</li>
<li>method), otherwise false.<br>
*/</li>
</ul>
<p>Patch attached.<br>
=end</p>