Message159687
| Author |
Mark.Shannon |
| Recipients |
Mark.Shannon |
| Date |
2012年04月30日.10:11:20 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1335780682.19.0.434044540817.issue14699@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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:
float.__dict__['fromhex'](float, "1")
and this succeeds:
float.__dict__['fromhex']("1")
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. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2012年04月30日 10:11:22 | Mark.Shannon | set | recipients:
+ Mark.Shannon |
| 2012年04月30日 10:11:22 | Mark.Shannon | set | messageid: <1335780682.19.0.434044540817.issue14699@psf.upfronthosting.co.za> |
| 2012年04月30日 10:11:21 | Mark.Shannon | link | issue14699 messages |
| 2012年04月30日 10:11:21 | Mark.Shannon | create |
|