Skip to content

Commit

Permalink
Merge pull request #2288 from andrehjr/fix-find-method-basic-object
Browse files Browse the repository at this point in the history
Make find-method compatible with BasicObject instances.
  • Loading branch information
andrehjr committed Oct 9, 2023
2 parents 5805952 + 2a47e31 commit 7406ee2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/pry/commands/find_method.rb
Expand Up @@ -128,7 +128,7 @@ def recurse_namespace(klass, done = {}, &block)
next if klass.autoload?(name)

begin
const = klass.const_get(name)
const = Pry::Method.singleton_class_of(klass.const_get(name))
rescue RescuableException # rubocop:disable Lint/HandleExceptions
# constant loading is an inexact science at the best of times,
# this often happens when a constant was .autoload? but someone
Expand Down
2 changes: 2 additions & 0 deletions spec/commands/find_method_spec.rb
Expand Up @@ -48,7 +48,9 @@ def tea_time?
end

it "should work with badly behaved constants" do
MyKlass::Z = BasicObject.new
MyKlass::X = Object.new

def (MyKlass::X).hash
raise "mooo"
end
Expand Down

0 comments on commit 7406ee2

Please sign in to comment.