Skip to content

IO#set_encoding returns nil instead of itself #4712

@bfontaine

Description

@bfontaine

Environment

$ jruby -v
jruby 9.1.12.0 (2.3.3) 2017-06-15 33c6439 Java HotSpot(TM) 64-Bit Server VM 25.131-b11 on 1.8.0_131-b11 +jit [darwin-x86_64]
$ ruby -v
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
$ uname -a
Darwin mbf.local 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64

Expected Behavior

$stdin.set_encoding(Encoding::UTF_8) should return itself, just like in MRI:

$ irb
>> $stdin.set_encoding(Encoding::UTF_8)
=> #<IO:<STDIN>>

Actual Behavior

$stdin.set_encoding(Encoding::UTF_8) returns nil (as we can see here).

This one-liner shows the issue:

puts $stdin.set_encoding(Encoding::UTF_8) ? "ok" : "not ok"
$ ruby set_encoding.rb
ok
$ jruby set_encoding.rb
not ok

Is there a reasoning behind this, or is this a bug?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions