[Python-bugs-list] [ python-Bugs-668980 ] classmethod does not check its arguments
SourceForge.net
noreply@sourceforge.net
Thu, 16 Jan 2003 06:52:21 -0800
Bugs item #668980, was opened at 2003-01-16 05:22
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=668980&group_id=5470
Category: Type/class unification
Group: None
Status: Open
Resolution: None
>Priority: 1
Submitted By: Martin v. Löwis (loewis)
Assigned to: Guido van Rossum (gvanrossum)
Summary: classmethod does not check its arguments
Initial Comment:
In 2.3a1, classmethod(3) works just fine. I think it
should be a type error.
It might be worthwhile to specialcase method objects,
so that
class X:
def foo(self):pass
X.foo=classmethod(X.foo)
does the "right" thing, i.e. is equivalent to
class X:
def foo(self):pass
foo=classmethod(foo)
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2003-01-16 09:52
Message:
Logged In: YES
user_id=6380
Not convinced; there are subtle things you might want to do
with classmethod (and staticmethod) that a type check would
prevent.
I could live with something that checks whether the argument
is callable.
There are definitely some weird things:
>>> C.x = classmethod(12)
>>> C.x()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
SystemError: ../Objects/classobject.c:2081: bad argument to
internal function
>>>
vs.
>>> C.x = staticmethod(12)
>>> C.x()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: 'int' object is not callable
>>>
Anyway I have bigger fish to fry for now.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=668980&group_id=5470