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

pdb's whatis command reports method as function #85775

Closed
iritkatriel opened this issue Aug 21, 2020 · 7 comments
Closed

pdb's whatis command reports method as function #85775

iritkatriel opened this issue Aug 21, 2020 · 7 comments
Labels
3.8 only security fixes 3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@iritkatriel
Copy link
Member

BPO 41609
Nosy @ambv, @miss-islington, @isidentical, @iritkatriel
PRs
  • bpo-41609: Fix output of pdb's whatis command for instance methods #21935
  • [3.8] bpo-41609: Fix output of pdb's whatis command for instance methods (GH-21935) #21976
  • [3.9] bpo-41609: Fix output of pdb's whatis command for instance methods (GH-21935) #21977
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-08-27.01:18:12.143>
    created_at = <Date 2020-08-21.15:31:01.652>
    labels = ['3.8', 'type-bug', 'library', '3.9', '3.10']
    title = "pdb's whatis command reports method as function"
    updated_at = <Date 2020-08-27.01:18:33.817>
    user = 'https://github.com/iritkatriel'

    bugs.python.org fields:

    activity = <Date 2020-08-27.01:18:33.817>
    actor = 'lukasz.langa'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-08-27.01:18:12.143>
    closer = 'lukasz.langa'
    components = ['Library (Lib)']
    creation = <Date 2020-08-21.15:31:01.652>
    creator = 'iritkatriel'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 41609
    keywords = ['patch']
    message_count = 7.0
    messages = ['375756', '375757', '375815', '375972', '375975', '375976', '375977']
    nosy_count = 4.0
    nosy_names = ['lukasz.langa', 'miss-islington', 'BTaskaya', 'iritkatriel']
    pr_nums = ['21935', '21976', '21977']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue41609'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

    @iritkatriel
    Copy link
    Member Author

    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)

    @iritkatriel iritkatriel added 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Aug 21, 2020
    @iritkatriel
    Copy link
    Member Author

    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.

    @iritkatriel
    Copy link
    Member Author

    It should really use inspect.* functions but I think that should be done separately from this fix.

    @ambv
    Copy link
    Contributor

    ambv commented Aug 27, 2020

    New changeset 022bc75 by Irit Katriel in branch 'master':
    bpo-41609: Fix output of pdb's whatis command for instance methods (GH-21935)
    022bc75

    @ambv
    Copy link
    Contributor

    ambv commented Aug 27, 2020

    New changeset 641279e by Miss Islington (bot) in branch '3.8':
    bpo-41609: Fix output of pdb's whatis command for instance methods (GH-21935) (bpo-21976)
    641279e

    @ambv
    Copy link
    Contributor

    ambv commented Aug 27, 2020

    New changeset 7361451 by Miss Islington (bot) in branch '3.9':
    bpo-41609: Fix output of pdb's whatis command for instance methods (GH-21935) (bpo-21977)
    7361451

    @ambv ambv closed this as completed Aug 27, 2020
    @ambv ambv closed this as completed Aug 27, 2020
    @ambv
    Copy link
    Contributor

    ambv commented Aug 27, 2020

    Thank you for your contribution, Irit!

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes 3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants