pry / pry-stack_explorer

Walk the stack in a Pry session
Other
454 stars 28 forks source link

pry-stack_explorer breaks `binding.pry` if self#== triggers a `binding.pry` #12

Closed ConradIrwin closed 11 years ago

ConradIrwin commented 11 years ago

Trying to debug the mail gem, I added in a binding.pry. Unfortunately the method I want to inspect is called by its == implementation, which pry-stack_explorer calls in a :before_session hook; so the binding.pry call recurses indefinitely (though slowly).

The error I encountered is here: http://git.io/br1WmQ ruby -I./lib -rmail -e'Mail::Message.new("foo").to_s'

A (silly) minimal example is:

require 'pry'
class Foo
  def ==(r)
    binding.pry
  end
end

Foo.new == 1

One easy fix would be to use .equal? instead of ==. Otherwise we can try wrapping some hooks in Pry.critical_section to save the user from the infinite recursion.