This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年04月30日 10:11 by Mark.Shannon, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| classmethoddescr_call.patch | Mark.Shannon, 2012年04月30日 10:11 | Patch to revision 2c27093fd11f | review | |
| classmethoddescr_call.patch | Mark.Shannon, 2012年05月01日 09:58 | review | ||
| Messages (3) | |||
|---|---|---|---|
| msg159687 - (view) | Author: Mark Shannon (Mark.Shannon) * (Python committer) | Date: 2012年04月30日 10:11 | |
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.
|
|||
| msg159748 - (view) | Author: Mark Shannon (Mark.Shannon) * (Python committer) | Date: 2012年05月01日 09:58 | |
New patch in response to review. |
|||
| msg159756 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年05月01日 13:56 | |
New changeset eab5120cc208 by Benjamin Peterson in branch '3.2': fix calling the classmethod descriptor directly (closes #14699) http://hg.python.org/cpython/rev/eab5120cc208 New changeset e1a200dfd5db by Benjamin Peterson in branch 'default': merge 3.2 (#14699) http://hg.python.org/cpython/rev/e1a200dfd5db New changeset 6484f5a51285 by Benjamin Peterson in branch '2.7': fix calling the classmethod descriptor directly (closes #14699) http://hg.python.org/cpython/rev/6484f5a51285 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:29 | admin | set | github: 58904 |
| 2012年05月01日 13:56:15 | python-dev | set | status: open -> closed nosy: + python-dev messages: + msg159756 resolution: fixed stage: resolved |
| 2012年05月01日 09:58:25 | Mark.Shannon | set | files:
+ classmethoddescr_call.patch messages: + msg159748 |
| 2012年04月30日 10:11:21 | Mark.Shannon | create | |