Project

General

Profile

Actions

Feature #17745

closed

`IO#close_on_exec=` returns different value when called with `send, __send__, public_send` or not

Feature #17745: `IO#close_on_exec=` returns different value when called with `send, __send__, public_send` or not

Added by kachick (Kenichi Kamiya) over 4 years ago. Updated about 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:102998]

Description

$ ruby -v -e 'p(STDIN.close_on_exec = 42)'
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin20]
42
$ ruby -v -e 'p(STDIN.__send__ :close_on_exec=, 42)'
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin20]
nil

Is this an intentional behavior?
ruby/spec has the test case, But I can't think any benefit this different returning value 🤔

PR: https://github.com/ruby/ruby/pull/4321

Updated by Eregon (Benoit Daloze) over 4 years ago Actions #1 [ruby-core:103001]

The PR looks good to me.

As you may know recv.foo= value always return value, no matter what the foo= method returns.
So in general the return value of assignment methods might differ and is probably best to be ignored.

Updated by nobu (Nobuyoshi Nakada) over 4 years ago Actions #2 [ruby-core:103004]

I also think the "returns nil" example should be removed simply.

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago Actions #3

  • Tracker changed from Bug to Feature
  • ruby -v deleted (ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin20])
  • Backport deleted (2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN)

Updated by Eregon (Benoit Daloze) over 4 years ago Actions #4 [ruby-core:104473]

Is there any reason to call close_on_exec= with send/__send__, or to use its return value?

I would be on the side of "changing this should not hurt", but it seems other committers do not necessarily agree (I guess their point is code should not rely on that anyway).

Updated by nobu (Nobuyoshi Nakada) about 4 years ago Actions #5

  • Status changed from Open to Closed

Applied in changeset git|42745ecae3ce95774f2fcc66467320471ca0460a.


Remove meaningless IO#close_on_exec= spec [Feature #17745]

Actions

Also available in: PDF Atom