[#61171] Re: [ruby-changes:33145] normal:r45224 (trunk): gc.c: fix build for testing w/o RGenGC — SASADA Koichi <ko1@...>
(2014/03/01 16:15), normal wrote:
[#61243] [ruby-trunk - Feature #9425] [PATCH] st: use power-of-two sizes to avoid slow modulo ops — normalperson@...
Issue #9425 has been updated by Eric Wong.
[#61359] [ruby-trunk - Bug #9609] [Open] [PATCH] vm_eval.c: fix misplaced RB_GC_GUARDs — normalperson@...
Issue #9609 has been reported by Eric Wong.
(2014/03/07 19:09), normalperson@yhbt.net wrote:
SASADA Koichi <ko1@atdot.net> wrote:
[#61424] [REJECT?] xmalloc/xfree: reduce atomic ops w/ thread-locals — Eric Wong <normalperson@...>
I'm unsure about this. I _hate_ the extra branches this adds;
Hi Eric,
SASADA Koichi <ko1@atdot.net> wrote:
(2014/03/14 2:12), Eric Wong wrote:
SASADA Koichi <ko1@atdot.net> wrote:
[#61452] [ruby-trunk - Feature #9632] [Open] [PATCH 0/2] speedup IO#close with linked-list from ccan — normalperson@...
Issue #9632 has been reported by Eric Wong.
[#61496] [ruby-trunk - Feature #9638] [Open] [PATCH] limit IDs to 32-bits on 64-bit systems — normalperson@...
Issue #9638 has been reported by Eric Wong.
[#61568] hash function for global method cache — Eric Wong <normalperson@...>
I came upon this because I noticed existing st numtable worked poorly
(2014/03/18 8:03), Eric Wong wrote:
SASADA Koichi <ko1@atdot.net> wrote:
what's the profit from using binary tree in place of hash?
Юрий Соколов <funny.falcon@gmail.com> wrote:
[#61687] [ruby-trunk - Bug #9606] Ocassional SIGSEGV inTestException#test_machine_stackoverflow on OpenBSD — normalperson@...
Issue #9606 has been updated by Eric Wong.
[#61760] [ruby-trunk - Feature #9632] [PATCH 0/2] speedup IO#close with linked-list from ccan — normalperson@...
Issue #9632 has been updated by Eric Wong.
[ruby-core:61180] [ruby-trunk - Feature #7596] Find::find should not silently ignores errors
Issue #7596 has been updated by Nobuyoshi Nakada.
`ignore_error: true`?
```diff
diff --git i/lib/find.rb w/lib/find.rb
index 6f3e428..c5fd35b 100644
--- i/lib/find.rb
+++ w/lib/find.rb
@@ -34,7 +34,7 @@ module Find
#
# See the +Find+ module documentation for an example.
#
- def find(*paths) # :yield: path
+ def find(*paths, ignore_error: true) # :yield: path
block_given? or return enum_for(__method__, *paths)
fs_encoding = Encoding.find("filesystem")
@@ -48,12 +48,14 @@ module Find
begin
s = File.lstat(file)
rescue Errno::ENOENT, Errno::EACCES, Errno::ENOTDIR, Errno::ELOOP, Errno::ENAMETOOLONG
+ raise unless ignore_error
next
end
if s.directory? then
begin
fs = Dir.entries(file, encoding: enc)
rescue Errno::ENOENT, Errno::EACCES, Errno::ENOTDIR, Errno::ELOOP, Errno::ENAMETOOLONG
+ raise unless ignore_error
next
end
fs.sort!
diff --git i/test/test_find.rb w/test/test_find.rb
index b924651..8bd6782 100644
--- i/test/test_find.rb
+++ w/test/test_find.rb
@@ -100,6 +100,16 @@ class TestFind < Test::Unit::TestCase
a = []
Find.find(d) {|f| a << f }
assert_equal([d, dir], a)
+
+ a = []
+ Find.find(d, ignore_error: true) {|f| a << f }
+ assert_equal([d, dir], a)
+
+ a = []
+ assert_raise_with_message(Errno::EACCES, /#{Regexp.quote(dir)}/) do
+ Find.find(d, ignore_error: false) {|f| a << f }
+ end
+ assert_equal([d, dir], a)
ensure
File.chmod(0700, dir)
end
@@ -115,6 +125,17 @@ class TestFind < Test::Unit::TestCase
a = []
Find.find(d) {|f| a << f }
assert_equal([d, dir, file], a)
+
+ a = []
+ Find.find(d, ignore_error: true) {|f| a << f }
+ assert_equal([d, dir, file], a)
+
+ a = []
+ assert_raise_with_message(Errno::EACCES, /#{Regexp.quote(file)}/) do
+ Find.find(d, ignore_error: false) {|f| a << f }
+ end
+ assert_equal([d, dir, file], a)
+
skip "no meaning test on Windows" if /mswin|mingw/ =~ RUBY_PLATFORM
assert_raise(Errno::EACCES) { File.lstat(file) }
ensure
```
----------------------------------------
Feature #7596: Find::find should not silently ignores errors
https://bugs.ruby-lang.org/issues/7596#change-45539
* Author: Hoylen Sue
* Status: Open
* Priority: Low
* Assignee: Yukihiro Matsumoto
* Category: lib
* Target version: next minor
----------------------------------------
=begin
The current implementation of (({Find::find})) silently ignores errors. It deliberately catches a number of (({Errno::*})) errors and just continues processing. This can cause unexpected (and often unnoticed) results when, for example, unreadable directories are encountered. Find will not recurse into those directories, but does also not tell the user that it is skipping them and their contents. This happened to me when there was a directory owned by another user.
I suggest making the default behaviour to ((*not*)) ignore errors. But then provide an ((*option*)) for the caller to indicate that they want (({find})) to keep going if it encounters some types of errors. This way the caller has control and the default behaviour is the one with "least surprise" for the caller.
Either that, or at least change the documentation to point out that the current implementation silently ignores errors and unreadable directories. That way the caller will know the limitations of the method.
http://www.ruby-doc.org/stdlib-1.9.3/libdoc/find/rdoc/Find.html
When updating the documentation, it would also be useful for documentation for the "Find" module's "find" class method to also point out that:
"The associated block is never called with "." or "..", except when they are explicitly provided as one of the arguments."
You can check this behavour by trying out different values for "testdirname" in the following command
ruby -e 'require "find"; Find.find(ARGV[0]) { |d| puts "<#{d}>" }' testdirname
=end
--
http://bugs.ruby-lang.org/