This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: pdb's whatis command reports method as function
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.10, Python 3.9, Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: BTaskaya, iritkatriel, lukasz.langa, miss-islington
Priority: normal Keywords: patch

Created on 2020-08-21 15:31 by iritkatriel, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 21935 merged iritkatriel, 2020-08-21 15:46
PR 21976 merged miss-islington, 2020-08-27 00:56
PR 21977 merged miss-islington, 2020-08-27 00:56
Messages (7)
msg375756 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2020-08-21 15:31
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--
> <stdin>(1)<module>()->None
(Pdb) whatis MyClass().mymethod
Function mymethod
(Pdb) MyClass().mymethod
<bound method MyClass.mymethod of <__main__.MyClass object at 0x0131D5C8>>
(Pdb)
msg375757 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2020-08-21 15:34
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__. 

I will submit a patch with a test and fix shortly.
msg375815 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2020-08-23 14:18
It should really use inspect.* functions but I think that should be done separately from this fix.
msg375972 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2020-08-27 00:51
New changeset 022bc7572f061e1d1132a4db9d085b29707701e7 by Irit Katriel in branch 'master':
bpo-41609: Fix output of pdb's whatis command for instance methods (GH-21935)
https://github.com/python/cpython/commit/022bc7572f061e1d1132a4db9d085b29707701e7
msg375975 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2020-08-27 01:17
New changeset 641279e6e51b5d2e10d3fbffe6330e47c94c4bb2 by Miss Islington (bot) in branch '3.8':
bpo-41609: Fix output of pdb's whatis command for instance methods (GH-21935) (#21976)
https://github.com/python/cpython/commit/641279e6e51b5d2e10d3fbffe6330e47c94c4bb2
msg375976 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2020-08-27 01:17
New changeset 7361451b97a30de0e758094ac83a1fb1f01ed5bb by Miss Islington (bot) in branch '3.9':
bpo-41609: Fix output of pdb's whatis command for instance methods (GH-21935) (#21977)
https://github.com/python/cpython/commit/7361451b97a30de0e758094ac83a1fb1f01ed5bb
msg375977 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2020-08-27 01:18
Thank you for your contribution, Irit!
History
Date User Action Args
2022-04-11 14:59:35adminsetgithub: 85775
2020-08-27 01:18:33lukasz.langasetmessages: + msg375977
2020-08-27 01:18:12lukasz.langasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-08-27 01:17:44lukasz.langasetmessages: + msg375976
2020-08-27 01:17:37lukasz.langasetmessages: + msg375975
2020-08-27 00:56:11miss-islingtonsetpull_requests: + pull_request21086
2020-08-27 00:56:02miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request21085
2020-08-27 00:51:16lukasz.langasetnosy: + lukasz.langa
messages: + msg375972
2020-08-23 14:18:10iritkatrielsetmessages: + msg375815
2020-08-22 22:58:36iritkatrielsetnosy: + BTaskaya
2020-08-21 15:46:01iritkatrielsetkeywords: + patch
stage: patch review
pull_requests: + pull_request21049
2020-08-21 15:34:02iritkatrielsetmessages: + msg375757
2020-08-21 15:31:01iritkatrielcreate