Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue14699] Calling a classmethod_descriptor directly raises a TypeError for wrong number of parameters.

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Apr 30, 2012, 3:11 AM

Post #1 of 3 (40 views)
Permalink
[issue14699] Calling a classmethod_descriptor directly raises a TypeError for wrong number of parameters.

New submission from Mark Shannon <mark [at] hotpy>:

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.

----------
components: Interpreter Core
files: classmethoddescr_call.patch
keywords: patch
messages: 159687
nosy: Mark.Shannon
priority: normal
severity: normal
status: open
title: Calling a classmethod_descriptor directly raises a TypeError for wrong number of parameters.
type: behavior
versions: Python 3.3
Added file: http://bugs.python.org/file25423/classmethoddescr_call.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14699>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 1, 2012, 2:58 AM

Post #2 of 3 (37 views)
Permalink
[issue14699] Calling a classmethod_descriptor directly raises a TypeError for wrong number of parameters. [In reply to]

Mark Shannon <mark [at] hotpy> added the comment:

New patch in response to review.

----------
Added file: http://bugs.python.org/file25431/classmethoddescr_call.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14699>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 1, 2012, 6:56 AM

Post #3 of 3 (37 views)
Permalink
[issue14699] Calling a classmethod_descriptor directly raises a TypeError for wrong number of parameters. [In reply to]

Roundup Robot <devnull [at] psf> added the comment:

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

----------
nosy: +python-dev
resolution: -> fixed
stage: -> committed/rejected
status: open -> closed

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14699>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.