Skip to content

Dir.foreach, Dir.new, Dir.open: Missing/incompatible encoding support. #3205

@Freaky

Description

@Freaky

Ruby 2.2.2:

 Dir.new("/var/empty", encoding: Encoding.find("filesystem")).to_a # => [".", ".."]
 Dir.open("/var/empty", encoding: Encoding.find("filesystem")).to_a # => [".", ".."]
 Dir.foreach("/var/empty", encoding: Encoding.find("filesystem")).to_a # => [".", ".."]

JRuby 9.0.0.0 yields, respectively:

ArgumentError: wrong number of arguments calling `initialize` (2 for 1)
ArgumentError: wrong number of arguments calling `open` (2 for 1)
TypeError: wrong argument type Hash (expected Encoding)

The following works in JRuby:

Dir.foreach("/var/empty", Encoding.find("filesystem")).to_a # => [".", ".."]
Dir.new("/var/empty").each(Encoding.find("filesystem")).to_a # => [".", ".."]

But in Ruby 2.2.2 these raise:

ArgumentError: wrong number of arguments (2 for 1)
ArgumentError: wrong number of arguments (1 for 0)

It would seem the resolution to #2547 in 26ed114 is incorrect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions