@@ -71,8 +71,7 @@ extern "C" PyObject *PyInit__lldb(void);
71
71
#define LLDB_USE_PYTHON_SET_INTERRUPT 0
72
72
#else
73
73
// PyErr_SetInterrupt was introduced in 3.2.
74
- #define LLDB_USE_PYTHON_SET_INTERRUPT \
75
- (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 2 ) || (PY_MAJOR_VERSION > 3 )
74
+ #define LLDB_USE_PYTHON_SET_INTERRUPT PY_VERSION_HEX >= 0x03020000
76
75
#endif
77
76
78
77
static ScriptInterpreterPythonImpl *GetPythonInterpreter (Debugger &debugger) {
@@ -92,7 +91,7 @@ namespace {
92
91
struct InitializePythonRAII {
93
92
public:
94
93
InitializePythonRAII () {
95
- #if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 8) || (PY_MAJOR_VERSION > 3)
94
+ #if PY_VERSION_HEX >= 0x03080000
96
95
PyConfig config;
97
96
PyConfig_InitPythonConfig (&config);
98
97
#endif
@@ -109,7 +108,7 @@ struct InitializePythonRAII {
109
108
return spec.GetPath ();
110
109
}();
111
110
if (!g_python_home.empty ()) {
112
- #if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 8) || (PY_MAJOR_VERSION > 3)
111
+ #if PY_VERSION_HEX >= 0x03080000
113
112
PyConfig_SetBytesString (&config, &config.home , g_python_home.c_str ());
114
113
#else
115
114
size_t size = 0 ;
@@ -143,7 +142,7 @@ struct InitializePythonRAII {
143
142
PyImport_AppendInittab (" _lldb" , LLDBSwigPyInit);
144
143
}
145
144
146
- #if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 8) || (PY_MAJOR_VERSION > 3)
145
+ #if PY_VERSION_HEX >= 0x03080000
147
146
config.install_signal_handlers = 0 ;
148
147
Py_InitializeFromConfig (&config);
149
148
PyConfig_Clear (&config);
@@ -152,7 +151,7 @@ struct InitializePythonRAII {
152
151
// Python < 3.2 and Python >= 3.2 reversed the ordering requirements for
153
152
// calling `Py_Initialize` and `PyEval_InitThreads`. < 3.2 requires that you
154
153
// call `PyEval_InitThreads` first, and >= 3.2 requires that you call it last.
155
- #if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 2)
154
+ #if PY_VERSION_HEX >= 0x03020000
156
155
Py_InitializeEx (0 );
157
156
InitializeThreadsPrivate ();
158
157
#else
@@ -182,15 +181,15 @@ struct InitializePythonRAII {
182
181
// would always return `true` and `PyGILState_Ensure/Release` flow would be
183
182
// executed instead of unlocking GIL with `PyEval_SaveThread`. When
184
183
// an another thread calls `PyGILState_Ensure` it would get stuck in deadlock.
185
- #if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7) || (PY_MAJOR_VERSION > 3)
184
+ #if PY_VERSION_HEX >= 0x03070000
186
185
// The only case we should go further and acquire the GIL: it is unlocked.
187
186
if (PyGILState_Check ())
188
187
return ;
189
188
#endif
190
189
191
190
// `PyEval_ThreadsInitialized` was deprecated in Python 3.9 and removed in
192
191
// Python 3.13. It has been returning `true` always since Python 3.7.
193
- #if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 9) || (PY_MAJOR_VERSION < 3)
192
+ #if PY_VERSION_HEX < 0x03090000
194
193
if (PyEval_ThreadsInitialized ()) {
195
194
#else
196
195
if (true ) {
@@ -204,7 +203,7 @@ struct InitializePythonRAII {
204
203
205
204
// `PyEval_InitThreads` was deprecated in Python 3.9 and removed in
206
205
// Python 3.13.
207
- #if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 9) || (PY_MAJOR_VERSION < 3)
206
+ #if PY_VERSION_HEX < 0x03090000
208
207
return ;
209
208
}
210
209
0 commit comments