Bug #2171
closedKernel#respond_to_missing? Invoked for Unimplemented Methods
Description
=begin
Kernel#respond_to_missing? is called for methods that raise NotImplementedError, despite such methods not invoking #method_missing. I expected it not to be.
$ cat /tmp/notimp.rb
[:method_missing, :respond_to_missing?].each do |m|
File.define_singleton_method(m, ->(_){ p m; false })
end
[:glark, :lchmod].each do |m|
puts "<<#{m}>>"
File.respond_to?(m)
File.send(m)
end
$ ruby /tmp/notimp.rb
<>
:respond_to_missing?
:method_missing
<>
:respond_to_missing?
/tmp/notimp.rb:7:in lchmod': lchmod() function is unimplemented on this machine (NotImplementedError) from /tmp/notimp.rb:7:in
block in '
from /tmp/notimp.rb:4:in each' from /tmp/notimp.rb:4:in
'
=end
Updated by matz (Yukihiro Matsumoto) about 15 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
=begin
Applied in changeset r25234.
=end
Updated by nlugovoi (Nikolai Lugovoi) about 15 years ago
=begin
This update introduced some strange/broken behaviour of RSS parser -- test/rss/ were severely failing.
I had to use following patch to restore its work:
diff --git a/vm_method.c b/vm_method.c
index a31fb8b..22b4700 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -512,7 +512,7 @@ rb_method_boundp(VALUE klass, ID id, int ex)
rb_method_entry_t *me = rb_method_entry(klass, id);
if (me != 0) {
- if (ex && (me->flag & NOEX_PRIVATE)) {
- if ((ex & NOEX_PRIVATE) && (me->flag & NOEX_PRIVATE)) {
return FALSE;
}
if (!me->def) return 0;
@@ -1153,7 +1153,7 @@ basic_obj_respond_to(VALUE obj, ID id, int pub)
{
VALUE klass = CLASS_OF(obj);
- switch (rb_method_boundp(klass, id, pub|NOEX_RESPONDS)) {
- switch (rb_method_boundp(klass, id, (pub & 0x7F) |NOEX_RESPONDS)) {
case 2:
return FALSE;
case 0:
=end
Updated by nlugovoi (Nikolai Lugovoi) about 15 years ago
=begin
Actually, i pasted wrong patch in previous message.
This one is working and does not break as much -- using (ex & 0x7F):
--- a/vm_method.c
+++ b/vm_method.c
@@ -512,7 +512,7 @@ rb_method_boundp(VALUE klass, ID id, int ex)
rb_method_entry_t *me = rb_method_entry(klass, id);
if (me != 0) {
- if (ex && (me->flag & NOEX_PRIVATE)) {
- if ((ex & 0x7f) && (me->flag & NOEX_PRIVATE)) {
return FALSE;
}
if (!me->def) return 0;
@@ -1153,7 +1153,7 @@ basic_obj_respond_to(VALUE obj, ID id, int pub)
{
VALUE klass = CLASS_OF(obj);
- switch (rb_method_boundp(klass, id, pub|NOEX_RESPONDS)) {
- switch (rb_method_boundp(klass, id, (pub & 0x7F)|NOEX_RESPONDS)) {
case 2:
return FALSE;
case 0:
=end
Updated by marcandre (Marc-Andre Lafortune) about 15 years ago
- Status changed from Closed to Open
- Priority changed from 3 to Normal
=begin
=end
Updated by marcandre (Marc-Andre Lafortune) about 15 years ago
- Status changed from Open to Closed
=begin
=end