From: merch-redmine@jeremyevans.net
To: ruby-dev@ruby-lang.org
Subject: [ruby-dev:51087] [Ruby master Bug#18052] Find のignore_error オプションが、文字化けファイル遭遇時の例外に対応していない (Windows)
Date: Thu, 29 Jul 2021 16:48:34 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-93054.20210729164834.51770@ruby-lang.org> (raw)
In-Reply-To: <redmine.issue-18052.20210729135531.51770@ruby-lang.org>
Issue #18052 has been updated by jeremyevans0 (Jeremy Evans).
Status changed from Open to Closed
This was fixed in commit:230111802c2b9dcb8f391b489ff52a9dc0b41b87.
----------------------------------------
Bug #18052: Find のignore_error オプションが、文字化けファイル遭遇時の例外に対応していない (Windows)
https://bugs.ruby-lang.org/issues/18052#change-93054
* Author: araragi (Nagisawa Minoru)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 2.6.6p146 (2020-03-31 revision 67876) [x64-mingw32]
* Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
Find.find(".", ignore_error: true ) を指定しても、文字化けするファイルに出会った場合には、
ignore せずに例外を起こしてしまうようです。
https://docs.ruby-lang.org/ja/latest/class/Find.html
# Background
C:\>ver
Microsoft Windows [Version 10.0.19043.1110]
C:\ruby -v
ruby 2.6.6p146 (2020-03-31 revision 67876) [x64-mingw32]
# Input
# coding:cp932
p __ENCODING__
# cp932 では表現できないファイル名を作る(例はハングル文字)。
open("testfile-\uD7A3 .jpg", "w")
require "find"
Find.find(".", ignore_error: true ) {|f|
p f
}
# Output
#<Encoding:Windows-31J>
"."
"./testfile-???R?s?[.jpg"
Traceback (most recent call last):
25: from d:/opt/ruby/bin/irb:23:in `<main>'
24: from d:/opt/ruby/bin/irb:23:in `load'
23: from d:/opt/ruby/lib/ruby/gems/2.6.0/gems/irb-1.3.2/exe/irb:11:in `<top (required)>'
6: from (irb):10:in `<main>'
5: from d:/opt/ruby/lib/ruby/2.6.0/find.rb:43:in `find'
4: from d:/opt/ruby/lib/ruby/2.6.0/find.rb:43:in `each'
3: from d:/opt/ruby/lib/ruby/2.6.0/find.rb:48:in `block in find'
2: from d:/opt/ruby/lib/ruby/2.6.0/find.rb:48:in `catch'
1: from d:/opt/ruby/lib/ruby/2.6.0/find.rb:51:in `block (2 levels) in find'
d:/opt/ruby/lib/ruby/2.6.0/find.rb:51:in `lstat': Invalid argument @ rb_file_s_lstat - ./testfile-?[.jpg (Errno::EINVAL)
# Assessment
lib/ruby/3.0.0/find.rb:51 では以下となっていますが、
begin
s = File.lstat(file)
rescue Errno::ENOENT, Errno::EACCES, Errno::ENOTDIR, Errno::ELOOP, Errno::ENAMETOOLONG
raise unless ignore_error
next
end
文字化けしたファイルに遭遇した場合には、Errno::EINVAL が発生するのですが、それを考慮して ignore できていないように思われます。
--
https://bugs.ruby-lang.org/
prev parent reply other threads:[~2021-07-29 16:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-29 13:55 [ruby-dev:51086] " dexmerry-mx
2021-07-29 16:48 ` merch-redmine [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-93054.20210729164834.51770@ruby-lang.org \
--to=merch-redmine@jeremyevans.net \
--cc=ruby-dev@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).