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.

classification
Title: Python C-API "unused-parameter" warnings
Type: behavior Stage:
Components: Interpreter Core Versions: Python 3.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Devyn Johnson, vstinner
Priority: normal Keywords:

Created on 2016-01-22 14:06 by Devyn Johnson, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4341 merged petr.viktorin, 2017-11-08 15:51
Messages (5)
msg258809 - (view) Author: Devyn Johnson (Devyn Johnson) Date: 2016-01-22 14:06
When compiling Python C-API extensions with "-Wextra", warnings like 

warning: unused parameter ‘self’ [-Wunused-parameter]

appear for code (like below). It seems like a minor issue for a warning to appear when "PyObject *self, PyObject *args" is required. Is there an underlying issue in the API?

static PyObject *mathfunc_ismersenneprime(PyObject *self, PyObject *args) {
    sllint num;
    ASSERT_LONGLONG_ARG(num);
    if (num < (sllint)0) ERR_POSITIVE_INT;
    returnbool(islonglongmersenneprime(num));
}
msg258810 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-01-22 14:13
> Is there an underlying issue in the API?

You can use self if your code. If you don't need it, you can use Py_UNUSED() macro available since Python 3.4.
msg258811 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-01-22 14:14
Please don't open bug reports to ask questions on your own code. The bug tracker is not forum.
msg258813 - (view) Author: Devyn Johnson (Devyn Johnson) Date: 2016-01-22 14:46
Thank you and sorry.
msg305865 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-11-08 15:59
New changeset 2138163621196a186975796afb2b0a6aa335231d by Victor Stinner (Petr Viktorin) in branch 'master':
bpo-29179: Document the Py_UNUSED macro (#4341)
https://github.com/python/cpython/commit/2138163621196a186975796afb2b0a6aa335231d
History
Date User Action Args
2022-04-11 14:58:26adminsetgithub: 70367
2017-11-08 15:59:23vstinnersetmessages: + msg305865
2017-11-08 15:51:37petr.viktorinsetpull_requests: + pull_request4297
2016-01-22 14:46:51Devyn Johnsonsetmessages: + msg258813
2016-01-22 14:14:15vstinnersetstatus: open -> closed
resolution: not a bug
messages: + msg258811
2016-01-22 14:13:41vstinnersetnosy: + vstinner
messages: + msg258810
2016-01-22 14:06:20Devyn Johnsoncreate