Skip to content

help() of a method wrongly identifies it as a module-level function #94506

Open
@stevendaprano

Description

@stevendaprano

Consider the following class:

class K:
    def verbify(self):
        """Docstring"""

help() on the unbound method (actually a function) K.verbify wrongly identifies it as a module-level function, displaying this in Python3.10:

Help on function verbify in module __main__:

verbify(self)
    Docstring

It should identify the function using __qualname__ rather than __name__':

>>> K.verbify.__qualname__
'K.verbify'
>>> K.verbify.__name__
'verbify'

In contrast, help() on the bound method correctly identifies that verbify is a method belonging to K: help(K().verbify) displays verbify() method of __main__.K instance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixes3.12only security fixes3.13bugs and security fixesstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions