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

bpo-30938: Add pdb command to show user-owned variables #2732

Closed
wants to merge 1 commit into from

Conversation

FrontSide
Copy link

Add debugger commands "who" and "whos" - similar to the
ones from ipython - to list the names of user-owned variables (who)
and user-owned variable names together with the variable type
and the assigned value.

Manually tested.

Example:

>>> import pdb 
>>> x = 1 
>>> y = {'key': 'value'}
>>> pdb.set_trace()
(Pdb) who
x       y 
(Pdb) whos
Variable        Type    Data/Info
------------------------------  
x               int     1   
y               dict    {'key': 'value'}

Add a debugger commands "who" and "whos" - similar to the
ones from ipython - to list the names of user-owned variables (who)
and user-owned variable names together with the variable type
and the assigned value.

Manually tested.

Signed-off-by: David Rieger <david@isan.engineer>
@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

Thanks again to your contribution and we look forward to looking at it!

@mention-bot
Copy link

@FrontSide, thanks for your PR! By analyzing the history of the files in this pull request, we identified @birkenfeld, @tim-one and @Yhg1s to be potential reviewers.

@FrontSide
Copy link
Author

Just added my GitHub username to my bugs.python.org profile there.

@blueyed
Copy link
Contributor

blueyed commented Feb 15, 2019

Interesting!
Please add tests for it.

@iritkatriel
Copy link
Member

David, this has been open for a while. Are you planning to work on the tests? If not I wouldn't mind trying.

@FrontSide
Copy link
Author

Go for it @iritkatriel. Would love to see this getting merged : )

@iritkatriel
Copy link
Member

Is it deliberate that who shows globals and locals while whos shows only locals?

@FrontSide
Copy link
Author

@iritkatriel mhh, no sounds like a bug. I'd say it should probably always be globals.

@iritkatriel
Copy link
Member

iritkatriel commented Sep 1, 2020

I have some changes to your code in https://github.com/iritkatriel/cpython/tree/whos (I'm not sure how to make a PR into this branch. Also, this branch needs to be rebased).

The changes are (1) refactor out the bit that creates the user vars list. (2) I changed the code that iterates over them in whos so that globals are correctly shadowed by locals.

For whos, I think there is a lot more work to do to make it render neatly when the values are large.

I also added a test for who (but not for whos).

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Feb 20, 2022
Copy link
Contributor

@MaxwellDupre MaxwellDupre left a comment

Choose a reason for hiding this comment

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

Nice addition, but I would expect a NEWS entry and a change to the docs so that user are aware.

@iritkatriel
Copy link
Member

Closing since this was abandoned by the OP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting core review stale Stale PR or inactive for long period of time. type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants