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: inspect.isroutine does not return True for some bound builtin methods
Type: behavior Stage: resolved
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: BTaskaya, Wheerd, hakancelik, levkivskyi, miss-islington, yselivanov
Priority: normal Keywords: patch

Created on 2017-02-02 09:32 by Wheerd, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 19261 merged hakancelik, 2020-03-31 20:37
PR 31377 merged hakancelik, 2022-02-16 20:32
Messages (3)
msg286752 - (view) Author: Manuel Krebber (Wheerd) * Date: 2017-02-02 09:32
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 #29377. Here is the commit: https://github.com/python/cpython/commit/1947d33a0a1c2ba006397579ec6235528faea9fd
msg413330 - (view) Author: miss-islington (miss-islington) Date: 2022-02-16 12:46
New changeset 562c13f5734d406b2283cfca673611f4b496fdc7 by Hakan Çelik in branch 'main':
bpo-29418: Implement inspect.ismethodwrapper and fix inspect.isroutine for cases where methodwrapper is given (GH-19261)
https://github.com/python/cpython/commit/562c13f5734d406b2283cfca673611f4b496fdc7
msg413447 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2022-02-17 19:46
New changeset 02815d939362d4093a95da650e7fbddabf147eb0 by Hakan Çelik in branch 'main':
bpo-29418: Add inspect.ismethodwrapper to whatsnew (GH-31377)
https://github.com/python/cpython/commit/02815d939362d4093a95da650e7fbddabf147eb0
History
Date User Action Args
2022-04-11 14:58:42adminsetgithub: 73604
2022-02-17 19:46:14BTaskayasetnosy: + BTaskaya
messages: + msg413447
2022-02-16 20:32:14hakanceliksetpull_requests: + pull_request29527
2022-02-16 18:38:38BTaskayasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2022-02-16 12:46:38miss-islingtonsetnosy: + miss-islington
messages: + msg413330
2020-03-31 20:37:00hakanceliksetkeywords: + patch
nosy: + hakancelik

pull_requests: + pull_request18617
stage: patch review
2017-02-02 09:32:53Wheerdcreate