Skip to content

bpo-41609: Fix output of pdb's whatis command for instance methods #21935

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

Merged
merged 2 commits into from
Aug 27, 2020

Conversation

iritkatriel
Copy link
Member

@iritkatriel iritkatriel commented Aug 21, 2020

pdb's whatis command prints 'Function' instead of 'Method' for a bound method:

python.bat
Running Release|Win32 interpreter...
Python 3.10.0a0 (heads/master-dirty:12695f4c6d, Aug 21 2020, 15:48:06) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

class MyClass:
... def mymethod(self):
... pass
...
import pdb
pdb.set_trace()
--Return--
(1)()->None
(Pdb) whatis MyClass().mymethod
Function mymethod
(Pdb) MyClass().mymethod
<bound method MyClass.mymethod of <main.MyClass object at 0x0131D5C8>>
(Pdb)

The reason for this that it first checks whether there is a code attribute (which both methods and functions have) and only afterwards checks for func.code.

This PR adds the missing test and re-orders the code in do_whatis so that it first checks for Method and then for Function.

https://bugs.python.org/issue41609

@iritkatriel
Copy link
Member Author

@blueyed, @FrontSide, are you able to review this?

@FrontSide
Copy link

I don't think I'm the right person to review this. @iritkatriel

@ambv ambv merged commit 022bc75 into python:master Aug 27, 2020
@ambv
Copy link
Contributor

ambv commented Aug 27, 2020

Thanks! ✨ 🍰 ✨

@miss-islington
Copy link
Contributor

Thanks @iritkatriel for the PR, and @ambv for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Thanks @iritkatriel for the PR, and @ambv for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-21976 is a backport of this pull request to the 3.8 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label Aug 27, 2020
@bedevere-bot
Copy link

GH-21977 is a backport of this pull request to the 3.9 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 27, 2020
…ythonGH-21935)

(cherry picked from commit 022bc75)

Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 27, 2020
…ythonGH-21935)

(cherry picked from commit 022bc75)

Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
ambv pushed a commit that referenced this pull request Aug 27, 2020
…H-21935) (#21976)

(cherry picked from commit 022bc75)

Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
ambv pushed a commit that referenced this pull request Aug 27, 2020
…H-21935) (#21977)

(cherry picked from commit 022bc75)

Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
@iritkatriel iritkatriel deleted the pdb_whatis branch August 27, 2020 16:11
@iritkatriel iritkatriel added the type-bug An unexpected behavior, bug, or error label Dec 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants