1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/irb] Rescue a specific error

Rescuing StandardError is prone to bugs caused by a typo or obsoleted methods.

https://github.com/ruby/irb/commit/eb5260fcd5
This commit is contained in:
Takashi Kokubun 2021-06-30 21:04:56 +09:00 committed by git
parent e8c2b03ee1
commit acbddbe68c

View file

@ -24,7 +24,7 @@ module IRB
end
def dump_methods(o, klass, obj)
singleton_class = obj.singleton_class rescue nil
singleton_class = begin obj.singleton_class; rescue TypeError; nil end
maps = class_method_map((singleton_class || klass).ancestors)
maps.each do |mod, methods|
name = mod == singleton_class ? "#{klass}.methods" : "#{mod}#methods"