[issue29418] inspect.isroutine does not return True for some bound builtin methods

Manuel Krebber report at bugs.python.org
Thu Feb 2 04:32:53 EST 2017


New submission from Manuel Krebber:

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

----------
components: Library (Lib)
messages: 286752
nosy: Wheerd, levkivskyi, yselivanov
priority: normal
severity: normal
status: open
title: inspect.isroutine does not return True for some bound builtin methods
type: behavior

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29418>
_______________________________________


More information about the Python-bugs-list mailing list