[New-bugs-announce] [issue17008] Descriptor __get__() invoke is bypassed in the class context
stuart
report at bugs.python.org
Mon Jan 21 18:49:12 CET 2013
New submission from stuart:
I emulated a real classmethod using python:
class cm(object):
def __init__(self, o):
self.o = o
def __get__(self, obj, type=None):
return self.o.__get__(obj, type)
then I check whether it is workable in the interactive mode and it is working:
Python 2.7.3 (default, Sep 26 2012, 21:53:58)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def foo(cls):
... print cls
...
>>> cm = cm(foo)
>>> cm.__get__(int, type)
<bound method type.foo of <type 'int'>>
then I tried it in the real class but it failed:
>>> class C(object):
... @cm
... def foo(cls):
... print cls
...
>>> C.foo
<unbound method C.foo>
----------
components: None
messages: 180346
nosy: Stuart
priority: normal
severity: normal
status: open
title: Descriptor __get__() invoke is bypassed in the class context
type: behavior
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17008>
_______________________________________
More information about the New-bugs-announce
mailing list