1 /*
2  * The python header wrapper
3  *
4  * Copyright (C) 2009-2021, Joachim Metz <joachim.metz@gmail.com>
5  *
6  * Refer to AUTHORS for acknowledgements.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 #if !defined( _PYFWNT_PYTHON_H )
23 #define _PYFWNT_PYTHON_H
24 
25 #include <common.h>
26 
27 #if PY_MAJOR_VERSION < 3
28 
29 /* Fix defines in pyconfig.h
30  */
31 #undef _POSIX_C_SOURCE
32 #undef _XOPEN_SOURCE
33 
34 /* Fix defines in pyport.h
35  */
36 #undef HAVE_FSTAT
37 #undef HAVE_STAT
38 #undef HAVE_SSIZE_T
39 #undef HAVE_INT32_T
40 #undef HAVE_UINT32_T
41 #undef HAVE_INT64_T
42 #undef HAVE_UINT64_T
43 
44 #endif /* PY_MAJOR_VERSION < 3 */
45 
46 /* Define PY_SSIZE_T_CLEAN to silence:
47  * DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats
48  *
49  * PY_SSIZE_T_CLEAN was introduced in Python 2.5
50  */
51 #define PY_SSIZE_T_CLEAN
52 
53 #include <Python.h>
54 
55 /* Python compatibility macros
56  */
57 #if !defined( PyMODINIT_FUNC )
58 #if PY_MAJOR_VERSION >= 3
59 #define PyMODINIT_FUNC PyObject *
60 #else
61 #define PyMODINIT_FUNC void
62 #endif
63 #endif /* !defined( PyMODINIT_FUNC ) */
64 
65 #if !defined( PyVarObject_HEAD_INIT )
66 #define PyVarObject_HEAD_INIT( type, size ) \
67 	PyObject_HEAD_INIT( type ) \
68 	size,
69 
70 #endif /* !defined( PyVarObject_HEAD_INIT ) */
71 
72 #if PY_MAJOR_VERSION >= 3
73 #define Py_TPFLAGS_HAVE_ITER		0
74 #endif
75 
76 #if !defined( Py_TYPE )
77 #define Py_TYPE( object ) \
78 	( ( (PyObject *) object )->ob_type )
79 
80 #endif /* !defined( Py_TYPE ) */
81 
82 #endif /* !defined( _PYFWNT_PYTHON_H ) */
83 
84