Skip to content

Commit 5113de8

Browse files
author
Ralf W. Grosse-Kunstleve
committed
work around broken Python 2.2 include files
[SVN r15246]
1 parent e079006 commit 5113de8

2 files changed

Lines changed: 145 additions & 1 deletion

File tree

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
// Copy of Python 2.2/2.2.1 Python.h .
2+
// Changes marked with "Boost.Python modification"
3+
#ifndef Py_PYTHON_H
4+
#define Py_PYTHON_H
5+
/* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */
6+
7+
8+
/* Enable compiler features; switching on C lib defines doesn't work
9+
here, because the symbols haven't necessarily been defined yet. */
10+
#ifndef _GNU_SOURCE
11+
# define _GNU_SOURCE 1
12+
#endif
13+
14+
/* Forcing SUSv2 compatibility still produces problems on some
15+
platforms, True64 and SGI IRIX begin two of them, so for now the
16+
define is switched off. */
17+
#if 0
18+
#ifndef _XOPEN_SOURCE
19+
# define _XOPEN_SOURCE 500
20+
#endif
21+
#endif
22+
23+
/* Include nearly all Python header files */
24+
25+
#include "patchlevel.h"
26+
#include "pyconfig.h"
27+
28+
#ifdef HAVE_LIMITS_H
29+
#include <limits.h>
30+
#endif
31+
32+
/* pyconfig.h may or may not define DL_IMPORT */
33+
#ifndef DL_IMPORT /* declarations for DLL import/export */
34+
#define DL_IMPORT(RTYPE) RTYPE
35+
#endif
36+
#ifndef DL_EXPORT /* declarations for DLL import/export */
37+
#define DL_EXPORT(RTYPE) RTYPE
38+
#endif
39+
40+
#if defined(__sgi) && defined(WITH_THREAD) && !defined(_SGI_MP_SOURCE)
41+
#define _SGI_MP_SOURCE
42+
#endif
43+
44+
#include <stdio.h>
45+
#ifndef NULL
46+
# error "Python.h requires that stdio.h define NULL."
47+
#endif
48+
49+
#include <string.h>
50+
#include <errno.h>
51+
#ifdef HAVE_STDLIB_H
52+
#include <stdlib.h>
53+
#endif
54+
#if PY_MICRO_VERSION == 1 // Boost.Python modification: emulate Python 2.2
55+
#ifdef HAVE_UNISTD_H
56+
#include <unistd.h>
57+
#endif
58+
#endif // Boost.Python modification: emulate Python 2.2
59+
60+
/* CAUTION: Build setups should ensure that NDEBUG is defined on the
61+
* compiler command line when building Python in release mode; else
62+
* assert() calls won't be removed.
63+
*/
64+
#include <assert.h>
65+
66+
#include "pyport.h"
67+
68+
#include "pymem.h"
69+
70+
#include "object.h"
71+
#include "objimpl.h"
72+
73+
#include "pydebug.h"
74+
75+
#include "unicodeobject.h"
76+
#include "intobject.h"
77+
#include "longobject.h"
78+
#include "floatobject.h"
79+
#ifndef WITHOUT_COMPLEX
80+
#include "complexobject.h"
81+
#endif
82+
#include "rangeobject.h"
83+
#include "stringobject.h"
84+
#include "bufferobject.h"
85+
#include "tupleobject.h"
86+
#include "listobject.h"
87+
#include "dictobject.h"
88+
#include "methodobject.h"
89+
#include "moduleobject.h"
90+
#include "funcobject.h"
91+
#include "classobject.h"
92+
#include "fileobject.h"
93+
#include "cobject.h"
94+
#include "traceback.h"
95+
#include "sliceobject.h"
96+
#include "cellobject.h"
97+
extern "C" { // Boost.Python modification: provide missing extern "C"
98+
#include "iterobject.h"
99+
#include "descrobject.h"
100+
} // Boost.Python modification: provide missing extern "C"
101+
#include "weakrefobject.h"
102+
103+
#include "codecs.h"
104+
#include "pyerrors.h"
105+
106+
#include "pystate.h"
107+
108+
#include "modsupport.h"
109+
#include "pythonrun.h"
110+
#include "ceval.h"
111+
#include "sysmodule.h"
112+
#include "intrcheck.h"
113+
#include "import.h"
114+
115+
#include "abstract.h"
116+
117+
#define PyArg_GetInt(v, a) PyArg_Parse((v), "i", (a))
118+
#define PyArg_NoArgs(v) PyArg_Parse(v, "")
119+
120+
/* Convert a possibly signed character to a nonnegative int */
121+
/* XXX This assumes characters are 8 bits wide */
122+
#ifdef __CHAR_UNSIGNED__
123+
#define Py_CHARMASK(c) (c)
124+
#else
125+
#define Py_CHARMASK(c) ((c) & 0xff)
126+
#endif
127+
128+
#include "pyfpe.h"
129+
130+
/* These definitions must match corresponding definitions in graminit.h.
131+
There's code in compile.c that checks that they are the same. */
132+
#define Py_single_input 256
133+
#define Py_file_input 257
134+
#define Py_eval_input 258
135+
136+
#ifdef HAVE_PTH
137+
/* GNU pth user-space thread support */
138+
#include <pth.h>
139+
#endif
140+
#endif /* !Py_PYTHON_H */

include/boost/python/detail/wrap_python.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,11 @@ typedef int pid_t;
115115

116116
#endif // _WIN32
117117

118-
#include <Python.h>
118+
#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 2 && PY_MICRO_VERSION < 2
119+
# include <boost/python/detail/python22_fixed.h>
120+
#else
121+
# include <Python.h>
122+
#endif
119123

120124
#ifdef BOOST_PYTHON_ULONG_MAX_UNDEFINED
121125
# undef ULONG_MAX

0 commit comments

Comments
 (0)