Issue 668980: classmethod does not check its arguments (original) (raw)
This issue has been migrated to GitHub: https://github.com/python/cpython/issues/37781
classification
Title: | classmethod does not check its arguments | |
---|---|---|
Type: | Stage: | |
Components: | Interpreter Core | Versions: |
process
Status: | closed | Resolution: | |
---|---|---|---|
Dependencies: | Superseder: | ||
Assigned To: | loewis | Nosy List: | gvanrossum, loewis, nnorwitz |
Priority: | low | Keywords: |
Created on 2003-01-16 10:22 by loewis, last changed 2022-04-10 16:06 by admin. This issue is now closed.
Messages (3) | ||
---|---|---|
msg14099 - (view) | Author: Martin v. Löwis (loewis) * ![]() |
Date: 2003-01-16 10:22 |
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) | ||
msg14100 - (view) | Author: Guido van Rossum (gvanrossum) * ![]() |
Date: 2003-01-16 14:52 |
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 "", 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 "", line 1, in ? TypeError: 'int' object is not callable >>> Anyway I have bigger fish to fry for now. | ||
msg14101 - (view) | Author: Neal Norwitz (nnorwitz) * ![]() |
Date: 2003-07-02 03:52 |
Logged In: YES user_id=33168 classmethod(3) does raise a TypeError in 2.3b2. Should this be closed? |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-10 16:06:08 | admin | set | github: 37781 |
2003-01-16 10:22:58 | loewis | create |