[New-bugs-announce] [issue17680] self is lost if methods are callable objects
Roman Rader
report at bugs.python.org
Tue Apr 9 15:59:08 CEST 2013
New submission from Roman Rader:
Some strange behavior is observed while method in object substitutes with callable object.
For example:
-------------------------------------
class Meth(object):
def __call__(*args, **kwargs):
print (args, kwargs)
class X(object):
def some_method(*args, **kwargs):
print (args, kwargs)
x = X()
x.some_method(1)
X.some_method = Meth()
x.some_method(1)
-------------------------------------
Output
(<__main__.X object at 0xb72d408c>, 1) {}
(<__main__.Meth object at 0xb72d40cc>, 1) {}
-------------------------------------
So, second call lost caller object ("self").
I suppose second output should be
(<__main__.Meth object ...>, <__main__.X object ...>, 1) {}
Tested in Python 2.7 and Python 3.3.
----------
components: Interpreter Core
messages: 186410
nosy: Roman.Rader
priority: normal
severity: normal
status: open
title: self is lost if methods are callable objects
versions: Python 2.7, Python 3.3
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17680>
_______________________________________
More information about the New-bugs-announce
mailing list