Search code examples
pythondebuggingpdbipdb

In the Python debugger, how to step into the second method call on a line?


I'm trying to debug something in Django, and at some point in ipdb I ended up at the following stack trace:

ipdb> u
> /Users/kurtpeek/Documents/Dev/lucy2/lucy-web/dashboard/views/base.py(191)get()
    190     def get(self, request, *args, **kwargs):
--> 191         self.object = self.get_object()
    192         return super().get(request, *args, **kwargs)

I would like to step into the call to get_object(). However, if I type the s command, it steps into the self.object call (which is the __get__ method of the object, Django view):

ipdb> s
--Call--
> /Users/kurtpeek/.local/share/virtualenvs/lucy-web-CVxkrCFK/lib/python3.7/site-packages/django/db/models/manager.py(176)__get__()
    175 
--> 176     def __get__(self, instance, cls=None):
    177         if instance is not None:

Is it possible to step into the second method call on the line, not the first one? I've tried perusing the commands on https://docs.python.org/3/library/pdb.html#debugger-commands but couldn't find any.


Solution

  • I believe you can step into the first function with ‘s’ And then run to the end of the function with ‘r’. From there you should be able to step into the second function.