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

inspect.isroutine does not return True for some bound builtin methods #73604

Closed
wheerd mannequin opened this issue Feb 2, 2017 · 3 comments
Closed

inspect.isroutine does not return True for some bound builtin methods #73604

wheerd mannequin opened this issue Feb 2, 2017 · 3 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@wheerd
Copy link
Mannequin

wheerd mannequin commented Feb 2, 2017

BPO 29418
Nosy @1st1, @ilevkivskyi, @wheerd, @miss-islington, @isidentical, @hakancelik96
PRs
  • bpo-29418: Implement inspect.ismethodwrapper and fix inspect.isroutine for cases where methodwrapper is given #19261
  • bpo-29418: Add inspect.ismethodwrapper to whatsnew #31377
  • 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 2022-02-16.18:38:38.628>
    created_at = <Date 2017-02-02.09:32:53.346>
    labels = ['type-bug', 'library']
    title = 'inspect.isroutine does not return True for some bound builtin methods'
    updated_at = <Date 2022-02-17.19:46:14.964>
    user = 'https://github.com/wheerd'

    bugs.python.org fields:

    activity = <Date 2022-02-17.19:46:14.964>
    actor = 'BTaskaya'
    assignee = 'none'
    closed = True
    closed_date = <Date 2022-02-16.18:38:38.628>
    closer = 'BTaskaya'
    components = ['Library (Lib)']
    creation = <Date 2017-02-02.09:32:53.346>
    creator = 'Wheerd'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 29418
    keywords = ['patch']
    message_count = 3.0
    messages = ['286752', '413330', '413447']
    nosy_count = 6.0
    nosy_names = ['yselivanov', 'levkivskyi', 'Wheerd', 'miss-islington', 'BTaskaya', 'hakancelik']
    pr_nums = ['19261', '31377']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue29418'
    versions = []

    @wheerd
    Copy link
    Mannequin Author

    wheerd mannequin commented Feb 2, 2017

    Some of the builtin methods are not recognized as such by inspect.isroutine(). inspect.ismethoddescriptor() only returns True for the unbound versions of the methods but not the bound ones.

    For example:

    >>> inspect.isroutine(object.__str__)
    True
    >>> inspect.isroutine(object().__str__)
    False

    The second one should also return True as it does for user-defined classes:

    >>> class A:
    ...     def f(self):
    ...         pass
    >>> inspect.isroutine(A.f)
    True
    >>> inspect.isroutine(A().f)
    True

    The types needed for that have already been added to the types module in issue bpo-29377. Here is the commit: 1947d33

    @wheerd wheerd mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Feb 2, 2017
    @miss-islington
    Copy link
    Contributor

    New changeset 562c13f by Hakan Çelik in branch 'main':
    bpo-29418: Implement inspect.ismethodwrapper and fix inspect.isroutine for cases where methodwrapper is given (GH-19261)
    562c13f

    @isidentical
    Copy link
    Sponsor Member

    New changeset 02815d9 by Hakan Çelik in branch 'main':
    bpo-29418: Add inspect.ismethodwrapper to whatsnew (GH-31377)
    02815d9

    @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
    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