Skip to content

bpo-42524: pdb: additional documentation on retval #27612

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

romuald
Copy link
Contributor

@romuald romuald commented Aug 5, 2021

Add documentation on retvalstating that the return value itself can be
accessed via the __return__ local variable.

This is intended to let people know that they can access complex objects
using this variable (for example access __return__.thingy())

https://bugs.python.org/issue42524

Add documentation on `retval`stating that the return value itself can be
accessed via the `__return__` local variable.

This is intended to let people know that they can access complex objects
using this variable (for example access `__return__.thingy()`)
@@ -1238,6 +1238,8 @@ def do_args(self, arg):
def do_retval(self, arg):
"""retval
Print the return value for the last return of a function.
Alternatively, the return value can be accessed with the local
variable ``__return__``
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this sentence fits better in the documentation here: https://docs.python.org/3/library/pdb.html#pdbcommand-retval

For the docstring it's not really appropriate to point to an alternative.

@@ -107,6 +107,7 @@ def test_pdb_basic_commands():
... 'jump 8', # jump over second for loop
... 'return', # return out of function
... 'retval', # display return value
... '__return__', # access the return value
Copy link
Member

@iritkatriel iritkatriel Aug 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the function returns a string, this test doesn't really check that __return__ is the value rather than the string representation of the value. It also doesn't check that you can assign it to a local and inspect it (in other words - the test doesn't show that there is a difference between retval and __return__).

@python-cla-bot
Copy link

python-cla-bot bot commented Apr 6, 2025

The following commit authors need to sign the Contributor License Agreement:

CLA signed

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

Successfully merging this pull request may close these issues.

5 participants