ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:54404] [ruby-trunk - Bug #8284][Open] Expected behavior of Module#public_class_method
@ 2013-04-17 18:17 jacknagel (Jack Nagel)
  2013-04-18 19:22 ` [ruby-core:54441] [Backport 200 - Backport #8284] " moll (Andri Möll)
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: jacknagel (Jack Nagel) @ 2013-04-17 18:17 UTC (permalink / raw
  To: ruby-core


Issue #8284 has been reported by jacknagel (Jack Nagel).

----------------------------------------
Bug #8284: Expected behavior of Module#public_class_method
https://bugs.ruby-lang.org/issues/8284

Author: jacknagel (Jack Nagel)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: ruby 2.0.0p0 (2013-02-24 revision 39474) [i386-darwin10.8.0]


It was pointed out by Myron Marston (here: https://gist.github.com/myronmarston/5401829) that calling public_class_method on an anonymous module makes the named method public on Object, etc.

Object.define_method => NoMethodError
Module.new.public_class_method(:define_method)
Object.define_method => ArgumentError

Also of note, the same is not true when calling it on a class:

Object.define_method => NoMethodError
Class.new.public_class_method(:define_method)
Object.define_method => NoMethodError

which seems inconsistent given:

Module.new.singleton_class.ancestors => [Module, Object, Kernel, BasicObject]
Class.new.singleton_class.ancestors    => [Class, Module, Object, Kernel, BasicObject]


Is this a bug or expected behavior? If the latter, what is the correct explanation?


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [ruby-core:54441] [Backport 200 - Backport #8284] Expected behavior of Module#public_class_method
  2013-04-17 18:17 [ruby-core:54404] [ruby-trunk - Bug #8284][Open] Expected behavior of Module#public_class_method jacknagel (Jack Nagel)
@ 2013-04-18 19:22 ` moll (Andri Möll)
  2013-04-18 19:42 ` [ruby-core:54442] " jacknagel (Jack Nagel)
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: moll (Andri Möll) @ 2013-04-18 19:22 UTC (permalink / raw
  To: ruby-core


Issue #8284 has been updated by moll (Andri Möll).


Well, it was actually reported by me to the RSpec project (https://github.com/rspec/rspec-core/pull/873) and the example I gave there involved a regular, not an anonymous module. The patch you made, nobu, tests only with an anonymous module, but does the fix also solve the visibility leakage for non anonymous modules?

With Ruby v1.9.3p385:
>> Object.define_method
NoMethodError: private method `define_method' called for Object:Class
        from (irb):1
        from /usr/local/bin/irb:12:in `<main>'
>> module Foo
>>   public_class_method :define_method
>> end
=> Foo
>> Object.define_method
ArgumentError: wrong number of arguments (0 for 1)
        from (irb):3:in `define_method'
        from (irb):3
        from /usr/local/bin/irb:12:in `<main>'
----------------------------------------
Backport #8284: Expected behavior of Module#public_class_method
https://bugs.ruby-lang.org/issues/8284#change-38717

Author: jacknagel (Jack Nagel)
Status: Assigned
Priority: Normal
Assignee: nagachika (Tomoyuki Chikanaga)
Category: 
Target version: 


It was pointed out by Myron Marston (here: https://gist.github.com/myronmarston/5401829) that calling public_class_method on an anonymous module makes the named method public on Object, etc.

Object.define_method => NoMethodError
Module.new.public_class_method(:define_method)
Object.define_method => ArgumentError

Also of note, the same is not true when calling it on a class:

Object.define_method => NoMethodError
Class.new.public_class_method(:define_method)
Object.define_method => NoMethodError

which seems inconsistent given:

Module.new.singleton_class.ancestors => [Module, Object, Kernel, BasicObject]
Class.new.singleton_class.ancestors    => [Class, Module, Object, Kernel, BasicObject]


Is this a bug or expected behavior? If the latter, what is the correct explanation?


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [ruby-core:54442] [Backport 200 - Backport #8284] Expected behavior of Module#public_class_method
  2013-04-17 18:17 [ruby-core:54404] [ruby-trunk - Bug #8284][Open] Expected behavior of Module#public_class_method jacknagel (Jack Nagel)
  2013-04-18 19:22 ` [ruby-core:54441] [Backport 200 - Backport #8284] " moll (Andri Möll)
@ 2013-04-18 19:42 ` jacknagel (Jack Nagel)
  2013-04-18 19:44 ` [ruby-core:54443] " jacknagel (Jack Nagel)
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jacknagel (Jack Nagel) @ 2013-04-18 19:42 UTC (permalink / raw
  To: ruby-core


Issue #8284 has been updated by jacknagel (Jack Nagel).


It does:

irb(main):001:0> RUBY_DESCRIPTION
=> "ruby 2.1.0dev (2013-04-19 trunk 40359) [i386-darwin10.8.0]"
irb(main):002:0> Object.define_method
NoMethodError: private method `define_method' called for Object:Class
	from (irb):2
	from /Users/jacknagel/.rubies/ruby-2.1.0-dev/bin/irb:12:in `<main>'
irb(main):003:0> module Foo; public_class_method :define_method; end
=> Foo
irb(main):004:0> Object.define_method
NoMethodError: private method `define_method' called for Object:Class
	from (irb):4
	from /Users/jacknagel/.rubies/ruby-2.1.0-dev/bin/irb:12:in `<main>'

----------------------------------------
Backport #8284: Expected behavior of Module#public_class_method
https://bugs.ruby-lang.org/issues/8284#change-38718

Author: jacknagel (Jack Nagel)
Status: Assigned
Priority: Normal
Assignee: nagachika (Tomoyuki Chikanaga)
Category: 
Target version: 


It was pointed out by Myron Marston (here: https://gist.github.com/myronmarston/5401829) that calling public_class_method on an anonymous module makes the named method public on Object, etc.

Object.define_method => NoMethodError
Module.new.public_class_method(:define_method)
Object.define_method => ArgumentError

Also of note, the same is not true when calling it on a class:

Object.define_method => NoMethodError
Class.new.public_class_method(:define_method)
Object.define_method => NoMethodError

which seems inconsistent given:

Module.new.singleton_class.ancestors => [Module, Object, Kernel, BasicObject]
Class.new.singleton_class.ancestors    => [Class, Module, Object, Kernel, BasicObject]


Is this a bug or expected behavior? If the latter, what is the correct explanation?


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [ruby-core:54443] [Backport 200 - Backport #8284] Expected behavior of Module#public_class_method
  2013-04-17 18:17 [ruby-core:54404] [ruby-trunk - Bug #8284][Open] Expected behavior of Module#public_class_method jacknagel (Jack Nagel)
  2013-04-18 19:22 ` [ruby-core:54441] [Backport 200 - Backport #8284] " moll (Andri Möll)
  2013-04-18 19:42 ` [ruby-core:54442] " jacknagel (Jack Nagel)
@ 2013-04-18 19:44 ` jacknagel (Jack Nagel)
  2013-04-18 20:47 ` [ruby-core:54444] " marcandre (Marc-Andre Lafortune)
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jacknagel (Jack Nagel) @ 2013-04-18 19:44 UTC (permalink / raw
  To: ruby-core


Issue #8284 has been updated by jacknagel (Jack Nagel).


As an aside, I see that this is now marked Backport 200, but it would be great if it was backported to 1.9.3 as well.
----------------------------------------
Backport #8284: Expected behavior of Module#public_class_method
https://bugs.ruby-lang.org/issues/8284#change-38719

Author: jacknagel (Jack Nagel)
Status: Assigned
Priority: Normal
Assignee: nagachika (Tomoyuki Chikanaga)
Category: 
Target version: 


It was pointed out by Myron Marston (here: https://gist.github.com/myronmarston/5401829) that calling public_class_method on an anonymous module makes the named method public on Object, etc.

Object.define_method => NoMethodError
Module.new.public_class_method(:define_method)
Object.define_method => ArgumentError

Also of note, the same is not true when calling it on a class:

Object.define_method => NoMethodError
Class.new.public_class_method(:define_method)
Object.define_method => NoMethodError

which seems inconsistent given:

Module.new.singleton_class.ancestors => [Module, Object, Kernel, BasicObject]
Class.new.singleton_class.ancestors    => [Class, Module, Object, Kernel, BasicObject]


Is this a bug or expected behavior? If the latter, what is the correct explanation?


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [ruby-core:54444] [Backport 200 - Backport #8284] Expected behavior of Module#public_class_method
  2013-04-17 18:17 [ruby-core:54404] [ruby-trunk - Bug #8284][Open] Expected behavior of Module#public_class_method jacknagel (Jack Nagel)
                   ` (2 preceding siblings ...)
  2013-04-18 19:44 ` [ruby-core:54443] " jacknagel (Jack Nagel)
@ 2013-04-18 20:47 ` marcandre (Marc-Andre Lafortune)
  2013-04-19  4:37 ` [ruby-core:54452] " moll (Andri Möll)
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: marcandre (Marc-Andre Lafortune) @ 2013-04-18 20:47 UTC (permalink / raw
  To: ruby-core


Issue #8284 has been updated by marcandre (Marc-Andre Lafortune).


jacknagel (Jack Nagel) wrote:
> As an aside, I see that this is now marked Backport 200, but it would be great if it was backported to 1.9.3 as well.

I don't know if it will be, but in any case there is always `singleton_class.send :public, :define_method` instead or equivalent.

It's a bit more clear, IMO, as using "public_class_method" on a Module is a bit strange... Modules don't really have "class methods".

FWIW, there are no specs in RubySpec about "public_class_method" on a Module.
----------------------------------------
Backport #8284: Expected behavior of Module#public_class_method
https://bugs.ruby-lang.org/issues/8284#change-38720

Author: jacknagel (Jack Nagel)
Status: Assigned
Priority: Normal
Assignee: nagachika (Tomoyuki Chikanaga)
Category: 
Target version: 


It was pointed out by Myron Marston (here: https://gist.github.com/myronmarston/5401829) that calling public_class_method on an anonymous module makes the named method public on Object, etc.

Object.define_method => NoMethodError
Module.new.public_class_method(:define_method)
Object.define_method => ArgumentError

Also of note, the same is not true when calling it on a class:

Object.define_method => NoMethodError
Class.new.public_class_method(:define_method)
Object.define_method => NoMethodError

which seems inconsistent given:

Module.new.singleton_class.ancestors => [Module, Object, Kernel, BasicObject]
Class.new.singleton_class.ancestors    => [Class, Module, Object, Kernel, BasicObject]


Is this a bug or expected behavior? If the latter, what is the correct explanation?


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [ruby-core:54452] [Backport 200 - Backport #8284] Expected behavior of Module#public_class_method
  2013-04-17 18:17 [ruby-core:54404] [ruby-trunk - Bug #8284][Open] Expected behavior of Module#public_class_method jacknagel (Jack Nagel)
                   ` (3 preceding siblings ...)
  2013-04-18 20:47 ` [ruby-core:54444] " marcandre (Marc-Andre Lafortune)
@ 2013-04-19  4:37 ` moll (Andri Möll)
  2013-04-19 14:45 ` [ruby-core:54468] " nagachika (Tomoyuki Chikanaga)
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: moll (Andri Möll) @ 2013-04-19  4:37 UTC (permalink / raw
  To: ruby-core


Issue #8284 has been updated by moll (Andri Möll).


jacknagel (Jack Nagel) wrote:
> It does:

That's good. Now there's only a test missing for that. :)
----------------------------------------
Backport #8284: Expected behavior of Module#public_class_method
https://bugs.ruby-lang.org/issues/8284#change-38732

Author: jacknagel (Jack Nagel)
Status: Assigned
Priority: Normal
Assignee: nagachika (Tomoyuki Chikanaga)
Category: 
Target version: 


It was pointed out by Myron Marston (here: https://gist.github.com/myronmarston/5401829) that calling public_class_method on an anonymous module makes the named method public on Object, etc.

Object.define_method => NoMethodError
Module.new.public_class_method(:define_method)
Object.define_method => ArgumentError

Also of note, the same is not true when calling it on a class:

Object.define_method => NoMethodError
Class.new.public_class_method(:define_method)
Object.define_method => NoMethodError

which seems inconsistent given:

Module.new.singleton_class.ancestors => [Module, Object, Kernel, BasicObject]
Class.new.singleton_class.ancestors    => [Class, Module, Object, Kernel, BasicObject]


Is this a bug or expected behavior? If the latter, what is the correct explanation?


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [ruby-core:54468] [Backport 200 - Backport #8284] Expected behavior of Module#public_class_method
  2013-04-17 18:17 [ruby-core:54404] [ruby-trunk - Bug #8284][Open] Expected behavior of Module#public_class_method jacknagel (Jack Nagel)
                   ` (4 preceding siblings ...)
  2013-04-19  4:37 ` [ruby-core:54452] " moll (Andri Möll)
@ 2013-04-19 14:45 ` nagachika (Tomoyuki Chikanaga)
  2013-05-14  2:45 ` [ruby-core:54977] [Backport93 " usa (Usaku NAKAMURA)
  2017-10-21 12:20 ` [ruby-core:83458] [Backport193 Backport#8284][Rejected] " usa
  7 siblings, 0 replies; 9+ messages in thread
From: nagachika (Tomoyuki Chikanaga) @ 2013-04-19 14:45 UTC (permalink / raw
  To: ruby-core


Issue #8284 has been updated by nagachika (Tomoyuki Chikanaga).


I'll backport r40346 and r40371, and then move this ticket to Backport93.
----------------------------------------
Backport #8284: Expected behavior of Module#public_class_method
https://bugs.ruby-lang.org/issues/8284#change-38756

Author: jacknagel (Jack Nagel)
Status: Assigned
Priority: Normal
Assignee: nagachika (Tomoyuki Chikanaga)
Category: 
Target version: 


It was pointed out by Myron Marston (here: https://gist.github.com/myronmarston/5401829) that calling public_class_method on an anonymous module makes the named method public on Object, etc.

Object.define_method => NoMethodError
Module.new.public_class_method(:define_method)
Object.define_method => ArgumentError

Also of note, the same is not true when calling it on a class:

Object.define_method => NoMethodError
Class.new.public_class_method(:define_method)
Object.define_method => NoMethodError

which seems inconsistent given:

Module.new.singleton_class.ancestors => [Module, Object, Kernel, BasicObject]
Class.new.singleton_class.ancestors    => [Class, Module, Object, Kernel, BasicObject]


Is this a bug or expected behavior? If the latter, what is the correct explanation?


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [ruby-core:54977] [Backport93 - Backport #8284] Expected behavior of Module#public_class_method
  2013-04-17 18:17 [ruby-core:54404] [ruby-trunk - Bug #8284][Open] Expected behavior of Module#public_class_method jacknagel (Jack Nagel)
                   ` (5 preceding siblings ...)
  2013-04-19 14:45 ` [ruby-core:54468] " nagachika (Tomoyuki Chikanaga)
@ 2013-05-14  2:45 ` usa (Usaku NAKAMURA)
  2017-10-21 12:20 ` [ruby-core:83458] [Backport193 Backport#8284][Rejected] " usa
  7 siblings, 0 replies; 9+ messages in thread
From: usa (Usaku NAKAMURA) @ 2013-05-14  2:45 UTC (permalink / raw
  To: ruby-core


Issue #8284 has been updated by usa (Usaku NAKAMURA).


Something is missing to backport the patch to ruby_1_9_3.
I'll check it later. 
----------------------------------------
Backport #8284: Expected behavior of Module#public_class_method
https://bugs.ruby-lang.org/issues/8284#change-39327

Author: jacknagel (Jack Nagel)
Status: Assigned
Priority: Normal
Assignee: usa (Usaku NAKAMURA)
Category: 
Target version: 


It was pointed out by Myron Marston (here: https://gist.github.com/myronmarston/5401829) that calling public_class_method on an anonymous module makes the named method public on Object, etc.

Object.define_method => NoMethodError
Module.new.public_class_method(:define_method)
Object.define_method => ArgumentError

Also of note, the same is not true when calling it on a class:

Object.define_method => NoMethodError
Class.new.public_class_method(:define_method)
Object.define_method => NoMethodError

which seems inconsistent given:

Module.new.singleton_class.ancestors => [Module, Object, Kernel, BasicObject]
Class.new.singleton_class.ancestors    => [Class, Module, Object, Kernel, BasicObject]


Is this a bug or expected behavior? If the latter, what is the correct explanation?


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [ruby-core:83458] [Backport193 Backport#8284][Rejected] Expected behavior of Module#public_class_method
  2013-04-17 18:17 [ruby-core:54404] [ruby-trunk - Bug #8284][Open] Expected behavior of Module#public_class_method jacknagel (Jack Nagel)
                   ` (6 preceding siblings ...)
  2013-05-14  2:45 ` [ruby-core:54977] [Backport93 " usa (Usaku NAKAMURA)
@ 2017-10-21 12:20 ` usa
  7 siblings, 0 replies; 9+ messages in thread
From: usa @ 2017-10-21 12:20 UTC (permalink / raw
  To: ruby-core

Issue #8284 has been updated by usa (Usaku NAKAMURA).

Status changed from Assigned to Rejected

1.9.3 is out of date

----------------------------------------
Backport #8284: Expected behavior of Module#public_class_method
https://bugs.ruby-lang.org/issues/8284#change-67443

* Author: jacknagel (Jack Nagel)
* Status: Rejected
* Priority: Normal
* Assignee: usa (Usaku NAKAMURA)
----------------------------------------
It was pointed out by Myron Marston (here: https://gist.github.com/myronmarston/5401829) that calling public_class_method on an anonymous module makes the named method public on Object, etc.

Object.define_method => NoMethodError
Module.new.public_class_method(:define_method)
Object.define_method => ArgumentError

Also of note, the same is not true when calling it on a class:

Object.define_method => NoMethodError
Class.new.public_class_method(:define_method)
Object.define_method => NoMethodError

which seems inconsistent given:

Module.new.singleton_class.ancestors => [Module, Object, Kernel, BasicObject]
Class.new.singleton_class.ancestors    => [Class, Module, Object, Kernel, BasicObject]


Is this a bug or expected behavior? If the latter, what is the correct explanation?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-10-21 12:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-17 18:17 [ruby-core:54404] [ruby-trunk - Bug #8284][Open] Expected behavior of Module#public_class_method jacknagel (Jack Nagel)
2013-04-18 19:22 ` [ruby-core:54441] [Backport 200 - Backport #8284] " moll (Andri Möll)
2013-04-18 19:42 ` [ruby-core:54442] " jacknagel (Jack Nagel)
2013-04-18 19:44 ` [ruby-core:54443] " jacknagel (Jack Nagel)
2013-04-18 20:47 ` [ruby-core:54444] " marcandre (Marc-Andre Lafortune)
2013-04-19  4:37 ` [ruby-core:54452] " moll (Andri Möll)
2013-04-19 14:45 ` [ruby-core:54468] " nagachika (Tomoyuki Chikanaga)
2013-05-14  2:45 ` [ruby-core:54977] [Backport93 " usa (Usaku NAKAMURA)
2017-10-21 12:20 ` [ruby-core:83458] [Backport193 Backport#8284][Rejected] " usa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).