[issue27901] inspect.ismethod returns different results on the same basic code between Python2.7 Python3.5
R. David Murray
report at bugs.python.org
Tue Aug 30 15:46:52 EDT 2016
R. David Murray added the comment:
They are both correct. In 2.7 a class method is a method. In python3, a class method is a function.
As for the docs, the python3 docs say that it returns true for "a bound method on an object", while the python2 docs say "a bound or unbound method". A class method is not bound, and unbound method do not exist in python3. So the docs are correct as well. The notes about the difference could go into a porting guide, but I don't think they belong in the main docs.
To fix your code, just treat function objects on classes as what you are thinking of as methods. Because they are: any function assigned to a class becomes a bound method when invoked through an instance. I think that's even backward compatible, though I haven't checked.
----------
nosy: +r.david.murray
resolution: -> not a bug
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27901>
_______________________________________
More information about the Python-bugs-list
mailing list