Bug #9560

Backport fix for: "SimpleDelegator, a wrapped object with an open method and send" from 2.1 to 2.0

Added by Tobias Pfeiffer about 1 year ago. Updated 11 months ago.

[ruby-core:61053]
Status:Closed
Priority:Normal
Assignee:-
ruby -v:2.0.0-p451 Backport:1.9.3: REQUIRED, 2.0.0: REQUIRED, 2.1: DONTNEED

Description

There was an issue when you have an object with an open method wrapped by a SimpleDelegator and then use "send :open". This gist illustrates it: https://gist.github.com/PragTob/9189371

There was a github pull request fixing it: https://github.com/ruby/ruby/pull/449

It works for me on 2.1 (and 2.1.1) but it seems not to have been backported to the 2.0 series (tried -p451 today).

It'd be great if it were backported, could save people other than me quite some time and nerves :) It's a nasty thing to track down.

Cheers + thanks,
Tobi

Associated revisions

Revision 45747
Added by Usaku NAKAMURA 11 months ago

merge revision(s) 43682,43727,43752,43759: [Backport #9560]

* lib/delegate.rb (Delegator#send): override to get rid of global function interference.
  [Fixes GH-449]

* lib/delegate.rb (Delegator#send): separate from method_missing so
  that super calls proper method.

* lib/delegate.rb (Delegator#method_missing): try private methods defined in
  Kernel after the target.  [Fixes GH-449]

* lib/delegate.rb (SimpleDelegator#__getobj__): target object must be set.

* lib/delegate.rb (DelegateClass#__getobj__): ditto.

History

#1 Updated by Yui NARUSE about 1 year ago

  • Status changed from Open to Closed
  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN to 1.9.3: REQUIRED, 2.0.0: REQUIRED, 2.1: DONTNEED

Backport r43752

#2 Updated by Usaku NAKAMURA 11 months ago

  • Backport changed from 1.9.3: REQUIRED, 2.0.0: REQUIRED, 2.1: DONTNEED to 1.9.3: REQUIRED, 2.0.0: DONE, 2.1: DONTNEED

backported r43682 (test), r43727 (test), r43752 and r43759 into ruby_2_0_0 at r45747.

note: also implement assert_raise_with_message for these tests.

#3 Updated by Usaku NAKAMURA 11 months ago

  • Backport changed from 1.9.3: REQUIRED, 2.0.0: DONE, 2.1: DONTNEED to 1.9.3: REQUIRED, 2.0.0: REQUIRED, 2.1: DONTNEED

oops, it's reverted on ruby_2_0_0 because of incompatibility...

Also available in: Atom PDF