| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,10 +1,13 @@ | |||
| 1 | 1 | #!/usr/bin/env python3 | |
| 2 | 2 | ||
| 3 | + CFLAGS = ['-Wall', '-Wextra', '-Werror'] | ||
| 4 | + | ||
| 3 | 5 | def main(): | |
| 4 | 6 | from distutils.core import setup, Extension | |
| 5 | 7 | ||
| 6 | 8 | ext = Extension('test_pythoncapi_compat_cext', | |
| 7 | - sources=['test_pythoncapi_compat_cext.c']) | ||
| 9 | + sources=['test_pythoncapi_compat_cext.c'], | ||
| 10 | + extra_compile_args=CFLAGS) | ||
| 8 | 11 | ||
| 9 | 12 | setup(name="test_pythoncapi_compat", ext_modules=[ext]) | |
| 10 | 13 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,15 @@ | |||
| 7 | 7 | # define PYTHON3 1 | |
| 8 | 8 | #endif | |
| 9 | 9 | ||
| 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 | + | ||
| 10 | 19 | static PyObject* | |
| 11 | 20 | ASSERT_FAILED(const char *err_msg) | |
| 12 | 21 | { | |
@@ -15,7 +24,7 @@ ASSERT_FAILED(const char *err_msg) | |||
| 15 | 24 | } | |
| 16 | 25 | ||
| 17 | 26 | static PyObject * | |
| 18 | - test_object(PyObject *self, PyObject *ignored) | ||
| 27 | + test_object(PyObject *Py_UNUSED(module), PyObject* Py_UNUSED(ignored)) | ||
| 19 | 28 | { | |
| 20 | 29 | PyObject *obj = PyList_New(0); | |
| 21 | 30 | if (obj == NULL) { | |
@@ -54,7 +63,7 @@ test_object(PyObject *self, PyObject *ignored) | |||
| 54 | 63 | ||
| 55 | 64 | ||
| 56 | 65 | static PyObject * | |
| 57 | - test_steal_ref(PyObject *self, PyObject *ignored) | ||
| 66 | + test_steal_ref(PyObject *Py_UNUSED(module), PyObject* Py_UNUSED(ignored)) | ||
| 58 | 67 | { | |
| 59 | 68 | PyObject *obj = PyList_New(0); | |
| 60 | 69 | if (obj == NULL) { | |
@@ -83,7 +92,7 @@ test_steal_ref(PyObject *self, PyObject *ignored) | |||
| 83 | 92 | ||
| 84 | 93 | ||
| 85 | 94 | static PyObject * | |
| 86 | - test_frame(PyObject *self, PyObject *ignored) | ||
| 95 | + test_frame(PyObject *Py_UNUSED(module), PyObject* Py_UNUSED(ignored)) | ||
| 87 | 96 | { | |
| 88 | 97 | PyThreadState *tstate = PyThreadState_Get(); | |
| 89 | 98 | ||
@@ -136,7 +145,7 @@ test_frame(PyObject *self, PyObject *ignored) | |||
| 136 | 145 | ||
| 137 | 146 | ||
| 138 | 147 | static PyObject * | |
| 139 | - test_thread_state(PyObject *self, PyObject *ignored) | ||
| 148 | + test_thread_state(PyObject *Py_UNUSED(module), PyObject* Py_UNUSED(ignored)) | ||
| 140 | 149 | { | |
| 141 | 150 | PyThreadState *tstate = PyThreadState_Get(); | |
| 142 | 151 | ||
@@ -161,7 +170,7 @@ test_thread_state(PyObject *self, PyObject *ignored) | |||
| 161 | 170 | ||
| 162 | 171 | ||
| 163 | 172 | static PyObject * | |
| 164 | - test_interpreter(PyObject *self, PyObject *ignored) | ||
| 173 | + test_interpreter(PyObject *Py_UNUSED(module), PyObject* Py_UNUSED(ignored)) | ||
| 165 | 174 | { | |
| 166 | 175 | // test PyInterpreterState_Get() | |
| 167 | 176 | PyInterpreterState *interp = PyInterpreterState_Get(); | |
@@ -175,7 +184,7 @@ test_interpreter(PyObject *self, PyObject *ignored) | |||
| 175 | 184 | ||
| 176 | 185 | ||
| 177 | 186 | static PyObject * | |
| 178 | - test_calls(PyObject *self, PyObject *ignored) | ||
| 187 | + test_calls(PyObject *Py_UNUSED(module), PyObject* Py_UNUSED(ignored)) | ||
| 179 | 188 | { | |
| 180 | 189 | PyObject *func = (PyObject *)&PyUnicode_Type; | |
| 181 | 190 | ||
@@ -205,7 +214,7 @@ test_calls(PyObject *self, PyObject *ignored) | |||
| 205 | 214 | ||
| 206 | 215 | ||
| 207 | 216 | static PyObject * | |
| 208 | - test_gc(PyObject *self, PyObject *ignored) | ||
| 217 | + test_gc(PyObject *Py_UNUSED(module), PyObject* Py_UNUSED(ignored)) | ||
| 209 | 218 | { | |
| 210 | 219 | PyObject *tuple = PyTuple_New(1); | |
| 211 | 220 | Py_INCREF(Py_None); | |
@@ -287,7 +296,7 @@ test_module_addobjectref(PyObject *module) | |||
| 287 | 296 | ||
| 288 | 297 | ||
| 289 | 298 | static PyObject * | |
| 290 | - test_module(PyObject *self, PyObject *ignored) | ||
| 299 | + test_module(PyObject *Py_UNUSED(module), PyObject* Py_UNUSED(ignored)) | ||
| 291 | 300 | { | |
| 292 | 301 | PyObject *module = PyImport_ImportModule("sys"); | |
| 293 | 302 | if (module == NULL) { | |
@@ -313,15 +322,15 @@ test_module(PyObject *self, PyObject *ignored) | |||
| 313 | 322 | ||
| 314 | 323 | ||
| 315 | 324 | static 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} | ||
| 325 | 334 | }; | |
| 326 | 335 | ||
| 327 | 336 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments