New submission from SylvainDe:

Very uninteresting issue I've found while looking at the code.

In Objects/call.c, in _PyMethodDef_RawFastCallDict(PyMethodDef *method, 
PyObject *self, PyObject **arg...), we have


   no_keyword_error:
       PyErr_Format(PyExc_TypeError,
                    "%.200s() takes no keyword arguments",
                    method->ml_name, nargs);

The `nargs` seems pointless.

This issue is mosly opened to have a record number to open a commit but it 
raises a few questions:

 - would it make sense to try to use GCC/CLang's logic around __attribute__ to 
have this kind of things checked during compilation as much as possible ?

 - would it make sense to define very small functions wrapping some calls to 
`PyErr_Format` so that one can use function with a very clear signature at 
(almost) no cost? This would be specially relevant for error raised in multiple 
places with the same message (The trio PyMethodDef 
*method/PyExc_TypeError/"%.200s() takes no keyword arguments" is a good 
candidate for this). I'd be happy for work on this but I'm afraid this would 
correspond to something Raymond Hettinger asks new comers not to do : "Don't be 
a picture straightener" ( 
https://speakerdeck.com/pybay2016/raymond-hettinger-keynote-core-developer-world
 ).

I've filled the impacted version as 3.7 as there is no real impacted version 
from a user point of view.

----------
components: Argument Clinic
messages: 290645
nosy: SylvainDe, larry
priority: normal
severity: normal
status: open
title: Useless argument in call to PyErr_Format
type: enhancement
versions: Python 3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29924>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to