Bug #10035

Find.find no longer accepts Pathname type as argument

Added by Herwin . 8 months ago. Updated 5 months ago.

[ruby-core:63713]
Status:Closed
Priority:Normal
Assignee:Akira Tanaka
ruby -v:ruby 2.1.2p95 (2014-05-08 revision 45877) [i686-linux] Backport:2.1: DONE

Description

In 2.1, a check for encoding of the paths parameter has been added to File.find. This works perfectly well for String parameters, but this results in a NoMethodError when a Pathname parameter is given. In my opinion a Pathname is a better suitable type to feed to Find.find than a String.

Associated revisions

Revision 47900
Added by Akira Tanaka 5 months ago

  • lib/find.rb (Find.find): Call to_path for arguments to obtain strings. [Bug #10035] Reported by Herwin.

Revision 47900
Added by Akira Tanaka 5 months ago

  • lib/find.rb (Find.find): Call to_path for arguments to obtain strings. [Bug #10035] Reported by Herwin.

Revision 47958
Added by Tomoyuki Chikanaga 5 months ago

merge revision(s) r47900: [Backport #10035]

* lib/find.rb (Find.find): Call to_path for arguments to obtain
  strings.
   [Bug #10035] Reported by Herwin.

History

#1 Updated by Robert A. Heiler 8 months ago

I don't think I can agree with you in regards to Pathname being a more suitable type - because I rarely use Pathname myself, with just about the single exception being code like this here:

Pathname(FILE).dirname.realpath.to_s

However, if this has been possible in the past then of course it should be preserved for the future as well.

Do you recall in which ruby version it was possible? I would like to test it myself as well (for curiousity reasons mostly).

#2 Updated by Herwin . 8 months ago

It works in ruby-2.0.0-p481.

If you compare the files lib/find.rb from both versions, you can see that some code for encoding has been added. This is where it breaks.

Another option might be to give the Pathname class a method encoding (which could just return self.to_s.encoding). There may be more places where this will break.

#3 Updated by Yui NARUSE 7 months ago

  • Status changed from Open to Assigned
  • Assignee set to Akira Tanaka

#4 Updated by Akira Tanaka 5 months ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

Applied in changeset r47900.


  • lib/find.rb (Find.find): Call to_path for arguments to obtain strings. [Bug #10035] Reported by Herwin.

#5 Updated by Tomoyuki Chikanaga 5 months ago

  • Backport changed from 2.1: UNKNOWN to 2.1: REQUIRED

ruby_2_1 branch has same problem.

#6 Updated by Tomoyuki Chikanaga 5 months ago

  • Backport changed from 2.1: REQUIRED to 2.1: DONE

Backported into ruby_2_1 at r47958.

Also available in: Atom PDF