Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a parameter to return command to enable returning custom object #237

Open
kajbaf opened this issue Oct 23, 2021 · 1 comment
Open

Comments

@kajbaf
Copy link

kajbaf commented Oct 23, 2021

I extensively use ipdb for debugging in the most strange situations, and many times I come across cases in which a specific function requires a predefined setup in prod to work as expected, which is hard to do during debugging.
In such cases I usually have to patch the mentioned function to behave as intended just to be able to continue debugging.

The suggestion is to add a parameter to the r(turn) command to patch the return value of the function. In this case, the current code will continue until returns, BUT it will return the INTENDED value.

    150 def very_complex_setup(**kwargs):
    151     # Make sure all dependencies are set up.
--> 152     result = other_setups(**kwargs)
    153     return result
ipdb> injected_result = True
ipdb> return injected_result

This command is expected to ignore the result and instead return injected_result as the value of the very_complex_setup function.

@gotcha
Copy link
Owner

gotcha commented Oct 25, 2021

I would suggest to try sthing like explained here: https://maurcz.github.io/posts/002-customizing-the-python-debugger/

Iow, I think that you can subclass ipdb yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants