[New-bugs-announce] [issue14699] Calling a classmethod_descriptor directly raises a TypeError for wrong number of parameters.
report at bugs.python.org
Mon Apr 30 12:11:22 CEST 2012
New submission from Mark Shannon <mark at hotpy.org>:
classmethod_descriptor should either be uncallable or (better) accept the correct number of arguments.
The classmethod_descriptor can be regarded as the Python object corresponding directly to the underlying C function, as well as a descriptor object.
When called it should check that its first parameter is a subtype of the type in which it was declared, and then pass that as the 'self' parameter to the underlying C function. Currently it passes the type in which it was declared as its 'self' parameter, adding the remaining parameters.
This means that this fails:
and this succeeds:
but it should be the other way around, otherwise it is impossible to pass a subtype as a parameter.
There is no tests for calling classmethod_descriptors in the test suite.
Attached patch includes tests and fixes the behaviour.
components: Interpreter Core
title: Calling a classmethod_descriptor directly raises a TypeError for wrong number of parameters.
versions: Python 3.3
Added file: http://bugs.python.org/file25423/classmethoddescr_call.patch
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce