77# define PYTHON3 1
88#endif
99
10+ #ifndef Py_UNUSED
11+ // Backport the macro for Python 3.5 and older
12+ # if defined(__GNUC__ ) || defined(__clang__ )
13+ # define Py_UNUSED (name ) _unused_ ## name __attribute__((unused))
14+ # else
15+ # define Py_UNUSED (name ) _unused_ ## name
16+ # endif
17+ #endif
18+
1019static PyObject *
1120ASSERT_FAILED (const char * err_msg )
1221{
@@ -15,7 +24,7 @@ ASSERT_FAILED(const char *err_msg)
1524}
1625
1726static PyObject *
18- test_object (PyObject * self , PyObject * ignored )
27+ test_object (PyObject * Py_UNUSED ( module ) , PyObject * Py_UNUSED ( ignored ) )
1928{
2029 PyObject * obj = PyList_New (0 );
2130 if (obj == NULL ) {
@@ -54,7 +63,7 @@ test_object(PyObject *self, PyObject *ignored)
5463
5564
5665static PyObject *
57- test_steal_ref (PyObject * self , PyObject * ignored )
66+ test_steal_ref (PyObject * Py_UNUSED ( module ) , PyObject * Py_UNUSED ( ignored ) )
5867{
5968 PyObject * obj = PyList_New (0 );
6069 if (obj == NULL ) {
@@ -83,7 +92,7 @@ test_steal_ref(PyObject *self, PyObject *ignored)
8392
8493
8594static PyObject *
86- test_frame (PyObject * self , PyObject * ignored )
95+ test_frame (PyObject * Py_UNUSED ( module ) , PyObject * Py_UNUSED ( ignored ) )
8796{
8897 PyThreadState * tstate = PyThreadState_Get ();
8998
@@ -136,7 +145,7 @@ test_frame(PyObject *self, PyObject *ignored)
136145
137146
138147static PyObject *
139- test_thread_state (PyObject * self , PyObject * ignored )
148+ test_thread_state (PyObject * Py_UNUSED ( module ) , PyObject * Py_UNUSED ( ignored ) )
140149{
141150 PyThreadState * tstate = PyThreadState_Get ();
142151
@@ -161,7 +170,7 @@ test_thread_state(PyObject *self, PyObject *ignored)
161170
162171
163172static PyObject *
164- test_interpreter (PyObject * self , PyObject * ignored )
173+ test_interpreter (PyObject * Py_UNUSED ( module ) , PyObject * Py_UNUSED ( ignored ) )
165174{
166175 // test PyInterpreterState_Get()
167176 PyInterpreterState * interp = PyInterpreterState_Get ();
@@ -175,7 +184,7 @@ test_interpreter(PyObject *self, PyObject *ignored)
175184
176185
177186static PyObject *
178- test_calls (PyObject * self , PyObject * ignored )
187+ test_calls (PyObject * Py_UNUSED ( module ) , PyObject * Py_UNUSED ( ignored ) )
179188{
180189 PyObject * func = (PyObject * )& PyUnicode_Type ;
181190
@@ -205,7 +214,7 @@ test_calls(PyObject *self, PyObject *ignored)
205214
206215
207216static PyObject *
208- test_gc (PyObject * self , PyObject * ignored )
217+ test_gc (PyObject * Py_UNUSED ( module ) , PyObject * Py_UNUSED ( ignored ) )
209218{
210219 PyObject * tuple = PyTuple_New (1 );
211220 Py_INCREF (Py_None );
@@ -287,7 +296,7 @@ test_module_addobjectref(PyObject *module)
287296
288297
289298static PyObject *
290- test_module (PyObject * self , PyObject * ignored )
299+ test_module (PyObject * Py_UNUSED ( module ) , PyObject * Py_UNUSED ( ignored ) )
291300{
292301 PyObject * module = PyImport_ImportModule ("sys" );
293302 if (module == NULL ) {
@@ -313,15 +322,15 @@ test_module(PyObject *self, PyObject *ignored)
313322
314323
315324static struct PyMethodDef methods [] = {
316- {"test_object" , test_object , METH_NOARGS },
317- {"test_steal_ref" , test_steal_ref , METH_NOARGS },
318- {"test_frame" , test_frame , METH_NOARGS },
319- {"test_thread_state" , test_thread_state , METH_NOARGS },
320- {"test_interpreter" , test_interpreter , METH_NOARGS },
321- {"test_calls" , test_calls , METH_NOARGS },
322- {"test_gc" , test_gc , METH_NOARGS },
323- {"test_module" , test_module , METH_NOARGS },
324- {NULL , NULL }
325+ {"test_object" , test_object , METH_NOARGS , NULL },
326+ {"test_steal_ref" , test_steal_ref , METH_NOARGS , NULL },
327+ {"test_frame" , test_frame , METH_NOARGS , NULL },
328+ {"test_thread_state" , test_thread_state , METH_NOARGS , NULL },
329+ {"test_interpreter" , test_interpreter , METH_NOARGS , NULL },
330+ {"test_calls" , test_calls , METH_NOARGS , NULL },
331+ {"test_gc" , test_gc , METH_NOARGS , NULL },
332+ {"test_module" , test_module , METH_NOARGS , NULL },
333+ {NULL , NULL , 0 , NULL }
325334};
326335
327336
0 commit comments