Skip to content

Commit c6d5d5a

Browse files
committed
Improve Python 2.x compatibility.
1 parent 93c5612 commit c6d5d5a

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

include/boost/python/module_init.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,15 @@ BOOST_PYTHON_DECL PyObject* init_module(char const* name, void(*)());
127127

128128
# endif
129129

130-
# ifdef HAS_CXX11
130+
# if defined(HAS_CXX11) && (PY_VERSION_HEX >= 0x03000000)
131131
# define BOOST_PYTHON_MODULE_INIT(name, ...) \
132132
void BOOST_PP_CAT(init_module_,name)(); \
133133
extern "C" BOOST_SYMBOL_EXPORT _BOOST_PYTHON_MODULE_INIT(name, __VA_ARGS__)
134134
# else
135135
# define BOOST_PYTHON_MODULE_INIT(name) \
136136
void BOOST_PP_CAT(init_module_,name)(); \
137137
extern "C" BOOST_SYMBOL_EXPORT _BOOST_PYTHON_MODULE_INIT(name)
138-
# endif // HAS_CXX11
138+
# endif // HAS_CXX11 && Python 3
139139

140140
# endif
141141

test/module_nogil.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ int get_value() {
88
return 1234;
99
}
1010

11-
#ifdef HAS_CXX11
12-
// C++11 build: test with mod_gil_not_used option
11+
#if defined(HAS_CXX11) && (PY_VERSION_HEX >= 0x03000000)
12+
// C++11 build with Python 3: test with mod_gil_not_used option
1313
BOOST_PYTHON_MODULE(module_nogil_ext, boost::python::mod_gil_not_used())
1414
{
1515
using namespace boost::python;
1616
def("get_value", get_value);
1717
}
1818
#else
19-
// C++98 build: test without optional arguments
19+
// C++98 build or Python 2: test without optional arguments
2020
BOOST_PYTHON_MODULE(module_nogil_ext)
2121
{
2222
using namespace boost::python;

0 commit comments

Comments
 (0)